Exemple #1
0
 /**
  * @param Price $price
  *
  * @return bool
  *
  * @throws UnexpectedCurrencyException
  */
 public function isEqualTo(Price $price)
 {
     if (!$this->currency->isEqualTo($price->getCurrency())) {
         throw new UnexpectedCurrencyException("Impossible to compare two prices with different currencies.");
     }
     return $this->amount === $price->getAmount();
 }
Exemple #2
0
 /**
  * @param CashFlow $cashflow
  *
  * @return bool
  *
  * @throws UnexpectedDateException
  */
 public function isEqualTo(CashFlow $cashflow)
 {
     if ($this->date->format('Y-m-d') !== $cashflow->getDate()->format('Y-m-d')) {
         throw new UnexpectedDateException('Impossible to compare two cashflows not belonging to the same day.');
     }
     return $this->price->isEqualTo($cashflow->getPrice());
 }
Exemple #3
0
 /**
  * @covers Price::isEqualTo
  * @expectedException \MonoidPoc\Exception\UnexpectedCurrencyException
  */
 public function testIsEqualToRaiseExceptionIfNecessary()
 {
     $price1 = new Price(25, 'EUR');
     $price2 = new Price(25, 'USD');
     $price1->isEqualTo($price2);
 }