本文整理汇总了PHP中Money::dollar方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::dollar方法的具体用法?PHP Money::dollar怎么用?PHP Money::dollar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money
的用法示例。
在下文中一共展示了Money::dollar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSumTimes
public function testSumTimes()
{
$fiveBucks = Money::dollar(5);
$tenFrancs = Money::franc(10);
$bank = new Bank();
$bank->addRate('CHF', 'USD', 2);
$step1 = new Sum($fiveBucks, $tenFrancs);
$sum = $step1->times(2);
$result = $bank->reduce($sum, 'USD');
$this->assertEquals(Money::dollar(20), $result);
}
示例2: unset
$t->ok($five->times(2)->equals(Money::dollar(10)));
$t->ok($five->times(3)->equals(Money::dollar(15)));
unset($five);
// multiplication
$five = Money::franc(5);
$t->ok($five->times(2)->equals(Money::franc(10)));
$t->ok($five->times(3)->equals(Money::franc(15)));
unset($five);
// equality
$five = Money::dollar(5);
$t->ok($five->equals(Money::dollar(5)), 'equals');
$t->ok(!$five->equals(Money::dollar(6)), 'equals');
$five = Money::franc(5);
$t->ok($five->equals(Money::franc(5)), 'equals');
$t->ok(!$five->equals(Money::franc(6)), 'equals');
$t->ok(!$five->equals(Money::dollar(5)), 'equals');
abstract class Money
{
protected $amount;
function equals($money)
{
return get_class($this) === get_class($money) && $this->amount === $money->amount;
}
static function dollar($amount)
{
return new Dollar($amount);
}
static function franc($amount)
{
return new Franc($amount);
}