コード例 #1
0
ファイル: Price.php プロジェクト: ndeg/monoid-poc
 /**
  * @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();
 }
コード例 #2
0
ファイル: CashFlow.php プロジェクト: ndeg/monoid-poc
 /**
  * @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());
 }
コード例 #3
0
ファイル: PriceTest.php プロジェクト: ndeg/monoid-poc
 /**
  * @covers Price::isEqualTo
  * @expectedException \MonoidPoc\Exception\UnexpectedCurrencyException
  */
 public function testIsEqualToRaiseExceptionIfNecessary()
 {
     $price1 = new Price(25, 'EUR');
     $price2 = new Price(25, 'USD');
     $price1->isEqualTo($price2);
 }