Total Complexity | 8 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class Cart extends SplObjectStorage implements CartInterface |
||
10 | { |
||
11 | private $id; |
||
12 | |||
13 | 10 | public function __construct(string $id, array $items = []) |
|
14 | { |
||
15 | 10 | $this->id = $id; |
|
16 | |||
17 | 10 | array_walk($items, [ $this, 'attach']); |
|
18 | 10 | } |
|
19 | |||
20 | 1 | public function getId(): string |
|
21 | { |
||
22 | 1 | return $this->id; |
|
23 | } |
||
24 | |||
25 | 2 | public function addItem(ItemInterface $item): bool |
|
34 | } |
||
35 | |||
36 | 2 | public function removeItem(ItemInterface $item): bool |
|
37 | { |
||
38 | 2 | if ($this->contains($item)) { |
|
39 | 1 | $this->detach($item); |
|
40 | |||
41 | 1 | return true; |
|
42 | } |
||
43 | |||
44 | 1 | return false; |
|
45 | } |
||
46 | |||
47 | 1 | public function cleanUp(): bool |
|
52 | } |
||
53 | |||
54 | 2 | public function isEmpty(): bool |
|
59 |