MoviesItem   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 8
c 3
b 1
f 2
lcom 1
cbo 1
dl 0
loc 73
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 3 1
A remove() 0 3 1
A clear() 0 3 1
A all() 0 3 1
A __toString() 0 4 1
A getMovie() 0 10 2
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