public function add(CashFlow $cashflow) { if ($this->getFormattedDate() !== $cashflow->getFormattedDate()) { throw new UnexpectedDateException('Impossible to compare two cashflows not belonging to the same day.'); } $newCashflow = clone $this; return $newCashflow->setPrice($this->price->add($cashflow->getPrice())); }
/** * @covers Prive::add * @expectedException \MonoidPoc\Exception\UnexpectedCurrencyException */ public function testAddRaisesExceptionIfNecessary() { $price1 = new Price(25, 'EUR'); $price2 = new Price(30, 'USD'); $price1->add($price2); }