PHP Class Money\Money

Afficher le fichier Open project: ulabox/money Class Usage Examples

Protected Properties

Свойство Type Description
$amount string The money amount
$currency Currency The amount currency

Méthodes publiques

Méthode Description
__callStatic ( string $method, array $arguments ) : Money Convenience factory method for a Money object
add ( Money $addend ) : Money Returns a new Money object that represents the sum of this and another Money object
amount ( ) : string Returns the value represented by this Money object
convertTo ( Currency $targetCurrency, numeric $conversionRate ) : Money Converts the currency of this Money object to a given target currency with a given conversion rate
currency ( ) : Currency Returns the currency of this Money object
divideBy ( numeric $divisor ) : Money Returns a new Money object that represents the divided value by the given factor
equals ( Money $other ) : boolean Checks whether the value represented by this object equals to the other
fromAmount ( numeric $amount, Currency $currency ) : Money Creates a Money object from its amount and currency
hasSameCurrencyAs ( Money $other ) : boolean Checks whether a Money has the same Currency as this
isGreaterThan ( Money $other ) : boolean Checks whether the value represented by this object is greater than the other
isGreaterThanOrEqualTo ( Money $other ) : boolean
isLessThan ( Money $other ) : boolean Checks whether the value represented by this object is less than the other
isLessThanOrEqualTo ( Money $other ) : boolean
isNegative ( ) : boolean Checks if the value represented by this object is negative
isPositive ( ) : boolean Checks if the value represented by this object is positive
isZero ( ) : boolean Checks if the value represented by this object is zero
multiplyBy ( numeric $multiplier ) : Money Returns a new Money object that represents the multiplied value by the given factor
round ( integer $scale ) : Money Rounds this Money to another scale
subtract ( Money $subtrahend ) : Money Returns a new Money object that represents the difference of this and another Money object

Private Methods

Méthode Description
__construct ( string $amount, Currency $currency )
assertNumeric ( numeric $value ) Asserts that a value is a valid numeric string
assertSameCurrencyAs ( Money $other ) Asserts that a Money has the same currency as this
compareTo ( Money $other ) : integer 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
compareTo0 ( ) : integer 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 0
newInstance ( string $amount ) : Money Returns a new Money instance based on the current one

Method Details

__callStatic() public static méthode

$fiveDollar = Money::USD(500);
public static __callStatic ( string $method, array $arguments ) : Money
$method string
$arguments array
Résultat Money

add() public méthode

Returns a new Money object that represents the sum of this and another Money object
public add ( Money $addend ) : Money
$addend Money
Résultat Money

amount() public méthode

Returns the value represented by this Money object
public amount ( ) : string
Résultat string

convertTo() public méthode

Converts the currency of this Money object to a given target currency with a given conversion rate
public convertTo ( Currency $targetCurrency, numeric $conversionRate ) : Money
$targetCurrency Currency
$conversionRate numeric
Résultat Money

currency() public méthode

Returns the currency of this Money object
public currency ( ) : Currency
Résultat Currency

divideBy() public méthode

Returns a new Money object that represents the divided value by the given factor
public divideBy ( numeric $divisor ) : Money
$divisor numeric
Résultat Money

equals() public méthode

Checks whether the value represented by this object equals to the other
public equals ( Money $other ) : boolean
$other Money
Résultat boolean

fromAmount() public static méthode

Creates a Money object from its amount and currency
public static fromAmount ( numeric $amount, Currency $currency ) : Money
$amount numeric
$currency Currency
Résultat Money

hasSameCurrencyAs() public méthode

Checks whether a Money has the same Currency as this
public hasSameCurrencyAs ( Money $other ) : boolean
$other Money
Résultat boolean

isGreaterThan() public méthode

Checks whether the value represented by this object is greater than the other
public isGreaterThan ( Money $other ) : boolean
$other Money
Résultat boolean

isGreaterThanOrEqualTo() public méthode

public isGreaterThanOrEqualTo ( Money $other ) : boolean
$other Money
Résultat boolean

isLessThan() public méthode

Checks whether the value represented by this object is less than the other
public isLessThan ( Money $other ) : boolean
$other Money
Résultat boolean

isLessThanOrEqualTo() public méthode

public isLessThanOrEqualTo ( Money $other ) : boolean
$other Money
Résultat boolean

isNegative() public méthode

Checks if the value represented by this object is negative
public isNegative ( ) : boolean
Résultat boolean

isPositive() public méthode

Checks if the value represented by this object is positive
public isPositive ( ) : boolean
Résultat boolean

isZero() public méthode

Checks if the value represented by this object is zero
public isZero ( ) : boolean
Résultat boolean

multiplyBy() public méthode

Returns a new Money object that represents the multiplied value by the given factor
public multiplyBy ( numeric $multiplier ) : Money
$multiplier numeric
Résultat Money

round() public méthode

Rounds this Money to another scale
public round ( integer $scale ) : Money
$scale integer
Résultat Money

subtract() public méthode

Returns a new Money object that represents the difference of this and another Money object
public subtract ( Money $subtrahend ) : Money
$subtrahend Money
Résultat Money

Property Details

$amount protected_oe property

The money amount
protected string $amount
Résultat string

$currency protected_oe property

The amount currency
protected Currency,money $currency
Résultat Currency