Currency
in package
Class designed to retrieve and handle basic currency-specific information, based on ISO4217-compliant data (code, exponent lenght, exponent use). Valid as of 12th Dec 2021.
Tags
Table of Contents
- $exponent : int|null
- $exponentUse : bool|null
- $picker : string|null
- __construct() : mixed
- Class constructor.
- getExponent() : int
- getExponentUse() : bool
- getParams() : array<string|int, mixed>
- Retrieves attributes.
- getPicker() : string
- reset() : void
- Resets object's attributes.
- set() : bool|self
- Public equivalent of checkCurrency method. If parameter is proper, fills object's attributes: - picker, - decimal exponent, - exponent's use.
- setExponent() : self
- Forces overwrite of decimal exponent. In this case, must be used after set() method.
- setExponentUse() : self
- Forces overwrite of exponent's use. In this case, must be used after set() method.
- assignSpecifics() : void
- Assigns specific attributes per recognized currency.
- checkCurrency() : bool
- Verifies input, including assigning attributes if verified.
Properties
$exponent
private
int|null
$exponent
= null
Length of assigned currency exponent.
$exponentUse
private
bool|null
$exponentUse
= null
Flag wether exponent is used/valid/available as a coin of banknote.
$picker
private
string|null
$picker
= null
Assigned currency picker.
Methods
__construct()
Class constructor.
public
__construct([string|int|null $c = null ]) : mixed
Parameters
- $c : string|int|null = null
-
ISO 4217 applicable currency number (3-characters-long numeric or string) or currency code (3-characters-long string).
Return values
mixed —getExponent()
public
getExponent() : int
Tags
Return values
int —Assigned currencies' exponent length.
getExponentUse()
public
getExponentUse() : bool
Tags
Return values
bool —Assigned currencies' exponent use status.
getParams()
Retrieves attributes.
public
getParams() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Array with keys corresponding to values: 'picker', 'exponent', 'exponentUse'.
getPicker()
public
getPicker([bool $flag = false ]) : string
Parameters
- $flag : bool = false
-
Returns picker in lowercase on FALSE, uppercase on TRUE. By default FALSE.
Tags
Return values
string —Currently assigned picker.
reset()
Resets object's attributes.
public
reset() : void
Return values
void —set()
Public equivalent of checkCurrency method. If parameter is proper, fills object's attributes: - picker, - decimal exponent, - exponent's use.
public
set([string $c = null ]) : bool|self
Parameters
- $c : string = null
-
Currency numeric code or alpha code according to ISO 4217 standard.
Tags
Return values
bool|self —Returns FALSE if check fails, self otherwise.
setExponent()
Forces overwrite of decimal exponent. In this case, must be used after set() method.
public
setExponent(int $x) : self
Parameters
- $x : int
-
Decimal point.
Return values
self —setExponentUse()
Forces overwrite of exponent's use. In this case, must be used after set() method.
public
setExponentUse(bool $b) : self
Parameters
- $b : bool
-
Flag boolean.
Return values
self —assignSpecifics()
Assigns specific attributes per recognized currency.
private
assignSpecifics(string $c) : void
Parameters
- $c : string
-
ISO 4217 applicable currency number (3-characters-long numeric or string) or currency code (3-characters-long string).
Tags
Return values
void —checkCurrency()
Verifies input, including assigning attributes if verified.
private
checkCurrency([string|int|null $c = null ]) : bool
Parameters
- $c : string|int|null = null
-
ISO 4217 applicable currency number (3-characters-long numeric or string) or currency code (3-characters-long string).
Tags
Return values
bool —TRUE on success, FALSE on fail.