PHP Class ValueObjects\Money\Money

Inheritance: implements ValueObjects\ValueObjectInterface
Afficher le fichier Open project: nicolopignatelli/valueobjects Class Usage Examples

Protected Properties

Свойство Type Description
$currency ValueObjects\Money\Currency
$money Money\Money

Méthodes publiques

Méthode Description
__construct ( integer $amount, ValueObjects\Money\Currency $currency ) Returns a Money object
__toString ( ) : string Returns a string representation of the Money value in format "CUR AMOUNT" (e.g.: EUR 1000)
add ( integer $quantity ) : Money Add an integer quantity to the amount and returns a new Money object.
fromNative ( ) : static Returns a Money object from native int amount and string currency code
getAmount ( ) : ValueObjects\Number\Integer Returns money amount
getCurrency ( ) : ValueObjects\Money\Currency Returns money currency
multiply ( ValueObjects\Number\Real $multiplier, ValueObjects\Number\RoundingMode $rounding_mode = null ) : Money Multiply the Money amount for a given number and returns a new Money object.
sameValueAs ( ValueObjects\ValueObjectInterface $money ) : boolean Tells whether two Currency are equal by comparing their amount and currency

Method Details

__construct() public méthode

Returns a Money object
public __construct ( integer $amount, ValueObjects\Money\Currency $currency )
$amount integer Amount expressed in the smallest units of $currency (e.g. cents)
$currency ValueObjects\Money\Currency Currency of the money object

__toString() public méthode

Returns a string representation of the Money value in format "CUR AMOUNT" (e.g.: EUR 1000)
public __toString ( ) : string
Résultat string

add() public méthode

Use a negative quantity for subtraction.
public add ( integer $quantity ) : Money
$quantity integer Quantity to add
Résultat Money

fromNative() public static méthode

Returns a Money object from native int amount and string currency code
public static fromNative ( ) : static
Résultat static

getAmount() public méthode

Returns money amount
public getAmount ( ) : ValueObjects\Number\Integer
Résultat ValueObjects\Number\Integer

getCurrency() public méthode

Returns money currency
public getCurrency ( ) : ValueObjects\Money\Currency
Résultat ValueObjects\Money\Currency

multiply() public méthode

Use 0 < Real $multipler < 1 for division.
public multiply ( ValueObjects\Number\Real $multiplier, ValueObjects\Number\RoundingMode $rounding_mode = null ) : Money
$multiplier ValueObjects\Number\Real
$rounding_mode ValueObjects\Number\RoundingMode Rounding mode of the operation. Defaults to RoundingMode::HALF_UP.
Résultat Money

sameValueAs() public méthode

Tells whether two Currency are equal by comparing their amount and currency
public sameValueAs ( ValueObjects\ValueObjectInterface $money ) : boolean
$money ValueObjects\ValueObjectInterface
Résultat boolean

Property Details

$currency protected_oe property

protected Currency,ValueObjects\Money $currency
Résultat ValueObjects\Money\Currency

$money protected_oe property

protected Money,Money $money
Résultat Money\Money