| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | final class Money |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var int |
||
| 12 | * @ORM\Column(type="integer") |
||
| 13 | */ |
||
| 14 | private $amount; |
||
| 15 | |||
| 16 | private function __construct(int $amount) |
||
| 17 | { |
||
| 18 | if ($amount < 0) { |
||
| 19 | throw new \InvalidArgumentException('Money value cannot be negative'); |
||
| 20 | } |
||
| 21 | |||
| 22 | $this->amount = $amount; |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function dollars(float $amount): Money |
||
| 26 | { |
||
| 27 | return new Money(round($amount * 100)); |
||
|
|
|||
| 28 | } |
||
| 29 | |||
| 30 | public static function cents(int $amount): Money |
||
| 33 | } |
||
| 34 | |||
| 35 | public function equals(Money $other): bool |
||
| 38 | } |
||
| 39 | } |