本文整理汇总了PHP中Money\Money::greaterThan方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::greaterThan方法的具体用法?PHP Money::greaterThan怎么用?PHP Money::greaterThan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money\Money
的用法示例。
在下文中一共展示了Money::greaterThan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: withdraw
/**
* Decrease this account current balance
*
* @param Money $amount
* @throws InsufficientFunds
* A member cannot withdraw more than it's account current balance
*/
public function withdraw(Money $amount)
{
if ($amount->greaterThan($this->balance)) {
throw new InsufficientFunds("Cannot withdraw {$amount->getAmount()}");
}
$this->balance = $this->balance->subtract($amount);
}
示例2: testComparison
public function testComparison()
{
$euro1 = new Money(1, new Currency('EUR'));
$euro2 = new Money(2, new Currency('EUR'));
$usd = new Money(1, new Currency('USD'));
$this->assertTrue($euro2->greaterThan($euro1));
$this->assertFalse($euro1->greaterThan($euro2));
$this->assertTrue($euro1->lessThan($euro2));
$this->assertFalse($euro2->lessThan($euro1));
$this->assertEquals(-1, $euro1->compare($euro2));
$this->assertEquals(1, $euro2->compare($euro1));
$this->assertEquals(0, $euro1->compare($euro1));
}
示例3: matches
/**
* Returns true if the provided amount is lower, than the current upper
* limit
*
* @param Money $other
* @return bool
*/
protected function matches($other)
{
return $this->upperLimit->greaterThan($other);
}