コード例 #1
0
ファイル: CashFlow.php プロジェクト: ndeg/monoid-poc
 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()));
 }
コード例 #2
0
ファイル: CashFlowSequence.php プロジェクト: ndeg/monoid-poc
 /**
  * @param CashFlow $cashflow
  * @throws \MonoidPoc\Exception\UnexpectedDateException
  */
 private function addCashFlow(CashFlow $cashflow)
 {
     $date = $cashflow->getFormattedDate();
     if (!isset($this->cashflows[$date])) {
         $this->cashflows[$date] = new CashFlow($date, 0, $this->currencyCode);
     }
     $this->cashflows[$date] = $this->cashflows[$date]->add($cashflow);
 }