IMoney extends JsonSerializable
Table of Contents
ROUND_HALF_UP | PHP_ROUND_HALF_UP | |
---|---|---|
ROUND_HALF_DOWN | PHP_ROUND_HALF_DOWN | |
ROUND_HALF_EVEN | PHP_ROUND_HALF_EVEN | |
ROUND_HALF_ODD | PHP_ROUND_HALF_ODD | |
ROUND_UP | 5 | |
ROUND_DOWN | 6 | |
ROUND_HALF_POSITIVE_INFINITY | 7 | |
ROUND_HALF_NEGATIVE_INFINITY | 8 | |
getFormattedAmount() | Retrieve the amount formatted as currency | string |
isSameCurrency() | Checks whether a IMoney has the same Currency as this. | bool |
equals() | Checks whether the value represented by this object equals to the other. | bool |
compare() | Returns an integer less than, equal to, or greater than zero if the value of this object is considered to be respectively less than, equal to, or greater than the other. | int |
greaterThan() | Checks whether the value represented by this object is greater than the other. | bool |
greaterThanOrEqual() | bool | |
lessThan() | Checks whether the value represented by this object is less than the other. | bool |
lessThanOrEqual() | bool | |
getAmount() | Returns the value represented by this object. | string |
getCurrency() | Returns the currency of this object. | Currency |
getMoney() | Retrieve the wrapped Money object instance | Money |
add() | Returns a new IMoney object that represents the sum of this and an other IMoney object. | IMoney |
subtract() | Returns a new IMoney object that represents the difference of this and an other IMoney object. | IMoney |
multiply() | Returns a new IMoney object that represents the multiplied value by the given factor. | IMoney |
divide() | Returns a new IMoney object that represents the divided value by the given factor. | IMoney |
mod() | Returns a new IMoney object that represents the remainder after dividing the value by the given factor. | IMoney |
allocate() | Allocate the money according to a list of ratios. | \buffalokiwi\magicgraph\money\IMoney[] |
allocateTo() | Allocate the money among N targets. | \buffalokiwi\magicgraph\money\IMoney[] |
ratioOf() | string | |
absolute() | IMoney | |
negative() | IMoney | |
isZero() | Checks if the value represented by this object is zero. | bool |
isPositive() | Checks if the value represented by this object is positive. | bool |
isNegative() | Checks if the value represented by this object is negative. | bool |
Constants
ROUND_HALF_UP
public
mixed
$ROUND_HALF_UP
= PHP_ROUND_HALF_UP
ROUND_HALF_DOWN
public
mixed
$ROUND_HALF_DOWN
= PHP_ROUND_HALF_DOWN
ROUND_HALF_EVEN
public
mixed
$ROUND_HALF_EVEN
= PHP_ROUND_HALF_EVEN
ROUND_HALF_ODD
public
mixed
$ROUND_HALF_ODD
= PHP_ROUND_HALF_ODD
ROUND_UP
public
mixed
$ROUND_UP
= 5
ROUND_DOWN
public
mixed
$ROUND_DOWN
= 6
ROUND_HALF_POSITIVE_INFINITY
public
mixed
$ROUND_HALF_POSITIVE_INFINITY
= 7
ROUND_HALF_NEGATIVE_INFINITY
public
mixed
$ROUND_HALF_NEGATIVE_INFINITY
= 8
Methods
getFormattedAmount()
Retrieve the amount formatted as currency
public
getFormattedAmount(
)
: string
Return values
string —amount
isSameCurrency()
Checks whether a IMoney has the same Currency as this.
public
isSameCurrency(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boolequals()
Checks whether the value represented by this object equals to the other.
public
equals(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boolcompare()
Returns an integer less than, equal to, or greater than zero if the value of this object is considered to be respectively less than, equal to, or greater than the other.
public
compare(
$other :
IMoney
)
: int
Parameters
- $other : IMoney
Return values
intgreaterThan()
Checks whether the value represented by this object is greater than the other.
public
greaterThan(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boolgreaterThanOrEqual()
public
greaterThanOrEqual(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boollessThan()
Checks whether the value represented by this object is less than the other.
public
lessThan(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boollessThanOrEqual()
public
lessThanOrEqual(
$other :
IMoney
)
: bool
Parameters
- $other : IMoney
Return values
boolgetAmount()
Returns the value represented by this object.
public
getAmount(
)
: string
Return values
stringgetCurrency()
Returns the currency of this object.
public
getCurrency(
)
: Currency
Return values
CurrencygetMoney()
Retrieve the wrapped Money object instance
public
getMoney(
)
: Money
Return values
Money —Money
add()
Returns a new IMoney object that represents the sum of this and an other IMoney object.
public
add(
...$addends :
\buffalokiwi\magicgraph\money\IMoney[]
)
: IMoney
Parameters
- $addends : \buffalokiwi\magicgraph\money\IMoney[]
Return values
IMoneysubtract()
Returns a new IMoney object that represents the difference of this and an other IMoney object.
public
subtract(
...$subtrahends :
\buffalokiwi\magicgraph\money\IMoney[]
)
: IMoney
Parameters
- $subtrahends : \buffalokiwi\magicgraph\money\IMoney[]
Return values
IMoneymultiply()
Returns a new IMoney object that represents the multiplied value by the given factor.
public
multiply(
$multiplier :
float|int|string
[, $roundingMode :
int
= self::ROUND_HALF_UP ]
)
: IMoney
Parameters
- $multiplier : float|int|string
- $roundingMode : int = self::ROUND_HALF_UP
Return values
IMoneydivide()
Returns a new IMoney object that represents the divided value by the given factor.
public
divide(
$divisor :
float|int|string
[, $roundingMode :
int
= self::ROUND_HALF_UP ]
)
: IMoney
Parameters
- $divisor : float|int|string
- $roundingMode : int = self::ROUND_HALF_UP
Return values
IMoneymod()
Returns a new IMoney object that represents the remainder after dividing the value by the given factor.
public
mod(
$divisor :
IMoney
)
: IMoney
Parameters
- $divisor : IMoney
Return values
IMoneyallocate()
Allocate the money according to a list of ratios.
public
allocate(
$ratios :
array
)
: \buffalokiwi\magicgraph\money\IMoney[]
Parameters
- $ratios : array
Return values
\buffalokiwi\magicgraph\money\IMoney[]allocateTo()
Allocate the money among N targets.
public
allocateTo(
$n :
int
)
: \buffalokiwi\magicgraph\money\IMoney[]
Parameters
- $n : int
Tags
Return values
\buffalokiwi\magicgraph\money\IMoney[]ratioOf()
public
ratioOf(
$money :
IMoney
)
: string
Parameters
- $money : IMoney
Return values
stringabsolute()
public
absolute(
)
: IMoney
Return values
IMoneynegative()
public
negative(
)
: IMoney
Return values
IMoneyisZero()
Checks if the value represented by this object is zero.
public
isZero(
)
: bool
Return values
boolisPositive()
Checks if the value represented by this object is positive.
public
isPositive(
)
: bool
Return values
boolisNegative()
Checks if the value represented by this object is negative.
public
isNegative(
)
: bool