public function appendMoney(Money $aMoney) { if ($aMoney->isZero()) { return; } $old = $this->findMoney($aMoney->currency()); if ($old == NULL) { $this->fMonies[] = $aMoney; return; } $keys = array_keys($this->fMonies); $max = count($keys); for ($i = 0; $i < $max; $i++) { if ($this->fMonies[$keys[$i]] === $old) { unset($this->fMonies[$keys[$i]]); break; } } $sum = $old->add($aMoney); if ($sum->isZero()) { return; } $this->fMonies[] = $sum; }