本文整理匯總了PHP中Money::franc方法的典型用法代碼示例。如果您正苦於以下問題:PHP Money::franc方法的具體用法?PHP Money::franc怎麽用?PHP Money::franc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Money
的用法示例。
在下文中一共展示了Money::franc方法的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
$five = Money::dollar(5);
$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);