本文整理汇总了PHP中Currency::equals方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::equals方法的具体用法?PHP Currency::equals怎么用?PHP Currency::equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::equals方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* @param money $amount
* @return money
*/
public function add(Money $amount)
{
if (!$this->currency->equals($amount->getCurrency())) {
throw new \InvalidArgumentException('Currency mismatch');
}
return new Money($this->currency, $this->amount + $amount->getValue());
}
示例2: isSameCurrency
/**
* Checks whether a Money has the same Currency as this.
*
* @param Money $other
*
* @return bool
*/
public function isSameCurrency(Money $other)
{
return $this->currency->equals($other->currency);
}
示例3: equals
/**
* Checks if an other CurrencyPair has the same parameters as this.
*
* @param CurrencyPair $other
*
* @return bool
*/
public function equals(CurrencyPair $other)
{
return $this->baseCurrency->equals($other->baseCurrency) && $this->counterCurrency->equals($other->counterCurrency) && $this->conversionRatio === $other->conversionRatio;
}
示例4: ensureCurrenciesMatch
private function ensureCurrenciesMatch(Currency $myCurrency, Currency $yourCurrency)
{
if (!$myCurrency->equals($yourCurrency)) {
throw new \InvalidArgumentException('Currency mismatch');
}
}
示例5: testCanCompareDifferentCurrencies
public function testCanCompareDifferentCurrencies()
{
$eur = new Currency('EUR');
$this->assertFalse($eur->equals($this->createUsd()));
}
示例6: isSameCurrencyAs
/**
* @param Money $money
* @return bool
*/
public function isSameCurrencyAs(Money $money)
{
return $this->currency->equals($money->getCurrency());
}