Completed
Push — master ( 5c637a...214bce )
by Julien
03:47
created

MoviesItem   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 1 1
A remove() 0 1 1
A clear() 0 1 1
A all() 0 1 1
A getMovie() 0 9 2
A __toString() 0 3 1
1
<?php
2
3
namespace App\Http\Cart;
4
use App\Http\Cart\Exception\ItemException;
5
use App\Http\Models\Movies;
6
7
/**
8
 * Interface ItemInterface
9
 * @package App\Http\Cart
10
 */
11
class MoviesItem implements ItemInterface{
12
13
    /**
14
     * @var $id
15
     */
16
    protected $id;
17
18
    /**
19
     * Constructor
20
     * @param $id
21
     */
22
    public function __construct($id){
23
24
        $this->id = $id;
25
    }
26
27
    /**
28
     * @return mixed
29
     */
30
    public function add(ItemInterface $item){}
31
32
    /**
33
     * @return mixed
34
     */
35
    public function remove(ItemInterface $item){}
36
37
    /**
38
     * @return mixed
39
     */
40
    public function clear(){}
41
42
    /**
43
     * @return mixed
44
     */
45
    public function all(){}
46
47
48
    /**
49
     * @param $id
50
     * @return mixed
51
     * @throws ItemException
52
     */
53
    public function getMovie(){
54
        $movie = Movies::find($this->id);
55
56
        if($movie->price !== 0){
57
            throw new ItemException('Le produit a un prix à 0');
58
        }
59
60
        return $movie;
61
    }
62
63
64
    /**
65
     * @return mixed
66
     * @throws ItemException
67
     */
68
    public function __toString(){
69
        return $this->getMovie()->id;
70
    }
71
72
}
73
74