public function addMoney(Money $m) { if ($this->currency() == $m->currency()) { return new Money($this->amount() + $m->amount(), $this->currency()); } return MoneyBag::create($this, $m); }
public function testSimpleBagAdd() { // [14 EUR] + {[12 EUR][7 USD]} == {[26 EUR][7 USD]} $expected = MoneyBag::create(new Money(26, 'EUR'), new Money(7, 'USD')); $this->assertTrue($expected->equals($this->f14EUR->add($this->fMB1))); }
public function addMoneyBag(MoneyBag $s) { return MoneyBag::create($s, $this); }