MoviesItem::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Cart;
4
5
use App\Http\Cart\Exception\ItemException;
6
use App\Http\Models\Movies;
7
8
/**
9
 * Interface ItemInterface.
10
 */
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)
24
    {
25
        $this->id = $id;
26
    }
27
28
    /**
29
     * @return mixed
30
     */
31
    public function add(ItemInterface $item)
32
    {
33
    }
34
35
    /**
36
     * @return mixed
37
     */
38
    public function remove(ItemInterface $item)
39
    {
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    public function clear()
46
    {
47
    }
48
49
    /**
50
     * @return mixed
51
     */
52
    public function all()
53
    {
54
    }
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()
80
    {
81
        return $this->getMovie()->id;
82
    }
83
}
84