| @@ 55-61 (lines=7) @@ | ||
| 52 | * @return Money |
|
| 53 | * @throw \InvalidArgumentException |
|
| 54 | */ |
|
| 55 | public function add(Money $moneyToAdd) |
|
| 56 | { |
|
| 57 | if (!$this->isSameCurrency($moneyToAdd)) { |
|
| 58 | throw new \InvalidArgumentException('Currencies does not match'); |
|
| 59 | } |
|
| 60 | return new Money($this->currency(), $this->value() + $moneyToAdd->value()); |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @param Money $moneyToSubtract |
|
| @@ 68-74 (lines=7) @@ | ||
| 65 | * @return Money |
|
| 66 | * @throw \InvalidArgumentException |
|
| 67 | */ |
|
| 68 | public function subtract(Money $moneyToSubtract) |
|
| 69 | { |
|
| 70 | if (!$this->isSameCurrency($moneyToSubtract)) { |
|
| 71 | throw new \InvalidArgumentException('Currencies does not match'); |
|
| 72 | } |
|
| 73 | return new Money($this->currency(), $this->value() - $moneyToSubtract->value()); |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * @param Money $moneyToCompare |
|