Documentation

PL extends Slownie
in package

Class used to transcribe float value into words in Polish language.

Tags
author

Piotr Bonk bonk.piotr@gmail.com

version
1.0.0

Table of Contents

$amountFull  : array<string|int, string>
$amountPart  : int
$currency  : Currency
$dictionary  : array<string|int, mixed>
$formatting  : array<string|int, string>
$fractions  : bool
$input  : float|string
$needsParsing  : bool
$pickerUse  : bool
__construct()  : void
Class constructor.
getCurrency()  : string
Returns currently set currency... in uppercase. That's pretty much it.
output()  : string
Returns amount in words.
setCurrency()  : self
Assigns currency.
setFormatting()  : self
Defines input string formatting.
setFractions()  : self
Sets flag for fractional notation true/false for minor rest.
setPickerUse()  : self
Sets flag to switch between translated currency name or currency picker use.
setValue()  : self
Sets value to interpret and translate.
translateTo()  : bool|object
Translates object from one language to another.
verifyCodes()  : bool
Developer method. Verifies if all keys from tei187\Resources\ISO4217\Xref::NUMBER_TO_CODE exist in language pack.
getBillions()  : string
Returns billions in words.
getCurrencyFull()  : string
Returns currency suffix.
getCurrencyMinor()  : string
Returns currency minors' suffix.
getHundreds()  : string
Returns hundreds part in words.
getLargeNumbers()  : string
Template method to get correct suffix per nth power of 10 and given value part.
getMillions()  : string
Returns millions in words.
getQuadrillions()  : string
Returns quadrillions in words.
getQuintillions()  : string
Returns quintillions in words.
getThousands()  : string
Returns thousands in words.
getTrillions()  : string
Returns trillions in words.
parse()  : bool
Parses input amount. Assigns values to $this->amountPart and $this->amountFull.
relayFractionMinors()  : string
Returns string x/y, where X is the minor rest and Y is power of 10 to the exponent length.
relayString()  : string
Sets full in-words transcription of the amount. Handles $this->amountFull;
translateNumber()  : string
Switches between translations for given value multiplied by N-power of ten.

Properties

$amountFull

protected array<string|int, string> $amountFull = []

Hold parts of amount (without minor parts), divided by hundreds mark.

$amountPart

protected int $amountPart = 0

Holds decimal parts of amount, only minors.

$dictionary

protected array<string|int, mixed> $dictionary = ['currencies' => ei187ResourcesISO4217PL::CURRENCIES, 'numbers' => ei187ResourcesPL::NUMBERS, 'xref' => ei187ResourcesISO4217Xref::NUMBER_TO_CODE, 'suffix' => ei187ResourcesPL::LARGE_NUMBERS]

Dictionary for translation purposes and cross-reference tables.

Tags
uses
PL::CURRENCIES
uses
ISO4217::NUMBER_TO_CODE
uses
PL::NUMBERS
uses
PL::LARGE_NUMBERS

$formatting

protected array<string|int, string> $formatting = ['thousands' => ",", "decimals" => "."]

Settings for number formatting.

$fractions

protected bool $fractions = false

Translate fully (with minors) or partially (with fractional notation). FALSE by default.

$input

protected float|string $input = 0

Whatever was passed as amount.

$needsParsing

protected bool $needsParsing = true

Flag to accertain if amount needs reparsing due to changes.

$pickerUse

protected bool $pickerUse = false

Flag to switch between translated currency name or currency picker.

Methods

__construct()

Class constructor.

public __construct([string|null $amount = null ][, string|Currency|null $currency = null ][, bool $fractionsUse = false ][, bool $pickerUse = false ]) : void
Parameters
$amount : string|null = null

Amount to process. Has to be well formed float or float-formed string.

$currency : string|Currency|null = null

A Currency class object or string ISO 4217 currency code or number (refer to tei187\Resources\ISO4217{lang}\Currencies or tei187\Resources\ISO4217\NUMBER_TO_CODE). By default null.

$fractionsUse : bool = false

If FALSE translates fully, if TRUE uses fractional notation for minor rest.

$pickerUse : bool = false

Sets flag to use or not use picker rather than full translation of currency.

Tags
uses
Currency
Return values
void —

getCurrency()

Returns currently set currency... in uppercase. That's pretty much it.

public getCurrency() : string

..

Tags
uses
Slownie::$currency
Return values
string —

output()

Returns amount in words.

public output([string|null $v = null ][, string $currency = null ][, bool|null $fractions = null ][, bool|null $picker = null ]) : string
Parameters
$v : string|null = null

Input value. Has to be float formed string.

$currency : string = null

ISO 4217 currency code or number.

$fractions : bool|null = null

If FALSE translates fully, if TRUE uses fractional notation for minor rest.

$picker : bool|null = null

Sets flag to use or not use picker rather than full translation of currency.

Tags
uses
Slownie::$input
Return values
string —

Output in words.

setCurrency()

Assigns currency.

public setCurrency([string|null $currency = null ]) : self
Parameters
$currency : string|null = null

Currency shortcode. Has to exist as index in tei187\Resources\ISO4217{lang}::CURRENCIES, or as cross-referenced ISO 4217 STRING index of tei187\Resources\ISO4217\Xref::NUMBER_TO_CODE (with leading zeroes), or 'none' (default).

Tags
uses
Slownie::$currency
Return values
self —

setFormatting()

Defines input string formatting.

public setFormatting([string $thousands = "." ][, string $decimals = "," ]) : self
Parameters
$thousands : string = "."

Thousands separator.

$decimals : string = ","

Decimal separator.

Tags
uses
Slownie::$formatting
Return values
self —

setFractions()

Sets flag for fractional notation true/false for minor rest.

public setFractions([bool $v = true ]) : self
Parameters
$v : bool = true
Tags
uses
Slownie::$fractions
Return values
self —

setPickerUse()

Sets flag to switch between translated currency name or currency picker use.

public setPickerUse([bool $v = true ]) : self
Parameters
$v : bool = true
Tags
uses
Slownie::$pickerUse
Return values
self —

setValue()

Sets value to interpret and translate.

public setValue([string|null $v = null ]) : self
Parameters
$v : string|null = null
Return values
self —

translateTo()

Translates object from one language to another.

public translateTo(string $lang) : bool|object
Parameters
$lang : string

Language to translate to. Must be a valid classname in \tei187\Slownie namespace, not equal to "Slownie" or "Currency".

Return values
bool|object —

verifyCodes()

Developer method. Verifies if all keys from tei187\Resources\ISO4217\Xref::NUMBER_TO_CODE exist in language pack.

public verifyCodes() : bool
Tags
uses
Xref::NUMBER_TO_CODE
uses

$dictionary

Return values
bool —

TRUE on correct, FALSE otherwise.

getBillions()

Returns billions in words.

protected getBillions([string $v = null ]) : string
Parameters
$v : string = null

Input billions part.

Return values
string —

Billions as string or empty.

getCurrencyFull()

Returns currency suffix.

protected getCurrencyFull([string|null $v = null ]) : string
Parameters
$v : string|null = null

Input last part of amount.

Tags
uses
PL::$dictionary
Return values
string —

Currency suffix or empty string if not found.

getCurrencyMinor()

Returns currency minors' suffix.

protected getCurrencyMinor([string|null $v = null ]) : string
Parameters
$v : string|null = null

Input rest.

Tags
uses
PL::$dictionary
Return values
string —

Currency minor suffix or empty string if not found.

getHundreds()

Returns hundreds part in words.

protected getHundreds([string|null $v = null ][, bool $minor = false ]) : string
Parameters
$v : string|null = null

Input hundreds part.

$minor : bool = false

Switch if minor.

Tags
uses
PL::$dictionary
Return values
string —

Hundreds as string or empty.

getLargeNumbers()

Template method to get correct suffix per nth power of 10 and given value part.

protected getLargeNumbers(int $power[, string|null $v = null ]) : string
Parameters
$power : int

N-th power of 10.

$v : string|null = null

Input value part.

Tags
uses
PL::$dictionary
Return values
string —

getMillions()

Returns millions in words.

protected getMillions([string $v = null ]) : string
Parameters
$v : string = null

Input millions part.

Return values
string —

Millions as string or empty.

getQuadrillions()

Returns quadrillions in words.

protected getQuadrillions([string $v = null ]) : string
Parameters
$v : string = null

Input quadrillions part.

Return values
string —

Quadrillions as string or empty.

getQuintillions()

Returns quintillions in words.

protected getQuintillions([string $v = null ]) : string
Parameters
$v : string = null

Input quintillions part.

Return values
string —

Quintillions as string or empty.

getThousands()

Returns thousands in words.

protected getThousands([string $v = null ]) : string
Parameters
$v : string = null

Input thousands part.

Return values
string —

Thousands as string or empty.

getTrillions()

Returns trillions in words.

protected getTrillions([string $v = null ]) : string
Parameters
$v : string = null

Input trillions part.

Return values
string —

Trillions as string or empty.

parse()

Parses input amount. Assigns values to $this->amountPart and $this->amountFull.

protected parse([string|null $v = null ]) : bool
Parameters
$v : string|null = null

Input amount.

Tags
uses
Slownie::$currency
uses
Slownie::$formatting
Return values
bool —

Returns TRUE is value is proper, FALSE if otherwise.

relayFractionMinors()

Returns string x/y, where X is the minor rest and Y is power of 10 to the exponent length.

protected relayFractionMinors() : string
Tags
uses
Slownie::$amountPart
uses
Slownie::$currency
Return values
string —

translateNumber()

Switches between translations for given value multiplied by N-power of ten.

protected translateNumber([int|null $power = null ][, int|null $digits = null ]) : string
Parameters
$power : int|null = null

N-th power of 10, corresponding with key in array.

$digits : int|null = null

Full amount part (000-999) to translate.

Return values
string —

Search results