1 | <?php declare(strict_types = 1); |
||
5 | class Cart |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * @var CartItem[] |
||
10 | */ |
||
11 | private $items = []; |
||
12 | |||
13 | /** |
||
14 | * @var Currency |
||
15 | */ |
||
16 | private $currency; |
||
17 | |||
18 | public function __construct(Currency $currency) |
||
22 | |||
23 | public function addItem(string $name, int $quantity, int $amount, string $description = null) |
||
27 | |||
28 | /** |
||
29 | * @return CartItem[] |
||
30 | */ |
||
31 | public function getItems(): array |
||
35 | |||
36 | public function getCurrentPrice(): Price |
||
37 | { |
||
38 | return new Price( |
||
39 | $this->countTotalAmount(), |
||
40 | $this->currency |
||
41 | ); |
||
42 | } |
||
43 | |||
44 | private function countTotalAmount(): int |
||
54 | |||
55 | } |
||
56 |