PHP 클래스 Money\Money

파일 보기 프로젝트 열기: ulabox/money 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$amount string The money amount
$currency Currency The amount currency

공개 메소드들

메소드 설명
__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

비공개 메소드들

메소드 설명
__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

메소드 상세

__callStatic() 공개 정적인 메소드

$fiveDollar = Money::USD(500);
public static __callStatic ( string $method, array $arguments ) : Money
$method string
$arguments array
리턴 Money

add() 공개 메소드

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

amount() 공개 메소드

Returns the value represented by this Money object
public amount ( ) : string
리턴 string

convertTo() 공개 메소드

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
리턴 Money

currency() 공개 메소드

Returns the currency of this Money object
public currency ( ) : Currency
리턴 Currency

divideBy() 공개 메소드

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

equals() 공개 메소드

Checks whether the value represented by this object equals to the other
public equals ( Money $other ) : boolean
$other Money
리턴 boolean

fromAmount() 공개 정적인 메소드

Creates a Money object from its amount and currency
public static fromAmount ( numeric $amount, Currency $currency ) : Money
$amount numeric
$currency Currency
리턴 Money

hasSameCurrencyAs() 공개 메소드

Checks whether a Money has the same Currency as this
public hasSameCurrencyAs ( Money $other ) : boolean
$other Money
리턴 boolean

isGreaterThan() 공개 메소드

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

isGreaterThanOrEqualTo() 공개 메소드

public isGreaterThanOrEqualTo ( Money $other ) : boolean
$other Money
리턴 boolean

isLessThan() 공개 메소드

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

isLessThanOrEqualTo() 공개 메소드

public isLessThanOrEqualTo ( Money $other ) : boolean
$other Money
리턴 boolean

isNegative() 공개 메소드

Checks if the value represented by this object is negative
public isNegative ( ) : boolean
리턴 boolean

isPositive() 공개 메소드

Checks if the value represented by this object is positive
public isPositive ( ) : boolean
리턴 boolean

isZero() 공개 메소드

Checks if the value represented by this object is zero
public isZero ( ) : boolean
리턴 boolean

multiplyBy() 공개 메소드

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

round() 공개 메소드

Rounds this Money to another scale
public round ( integer $scale ) : Money
$scale integer
리턴 Money

subtract() 공개 메소드

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

프로퍼티 상세

$amount 보호되어 있는 프로퍼티

The money amount
protected string $amount
리턴 string

$currency 보호되어 있는 프로퍼티

The amount currency
protected Currency,money $currency
리턴 Currency