1 | <?php |
||
11 | class MoviesItem implements ItemInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var |
||
15 | */ |
||
16 | protected $id; |
||
17 | |||
18 | /** |
||
19 | * Constructor. |
||
20 | * |
||
21 | * @param $id |
||
22 | */ |
||
23 | public function __construct($id) |
||
27 | |||
28 | /** |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function add(ItemInterface $item) |
||
34 | |||
35 | /** |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public function remove(ItemInterface $item) |
||
41 | |||
42 | /** |
||
43 | * @return mixed |
||
44 | */ |
||
45 | public function clear() |
||
48 | |||
49 | /** |
||
50 | * @return mixed |
||
51 | */ |
||
52 | public function all() |
||
55 | |||
56 | /** |
||
57 | * @param $id |
||
58 | * |
||
59 | * @throws ItemException |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | public function getMovie() |
||
64 | { |
||
65 | $movie = Movies::find($this->id); |
||
66 | |||
67 | if ($movie->price !== 0) { |
||
68 | throw new ItemException('Le produit a un prix à 0'); |
||
69 | } |
||
70 | |||
71 | return $movie; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @throws ItemException |
||
76 | * |
||
77 | * @return mixed |
||
78 | */ |
||
79 | public function __toString() |
||
83 | } |
||
84 |