Passed
Pull Request — master (#7)
by vincent
02:21
created

Movie   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 141
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 20
lcom 1
cbo 1
dl 0
loc 141
ccs 41
cts 41
cp 1
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getGenres() 0 8 2
A getTitle() 0 8 2
A getOverview() 0 8 2
A getReleaseDate() 0 8 2
A getOriginalTitle() 0 8 2
A getNote() 0 8 2
A getId() 0 4 1
A getIMDBId() 0 8 2
A getTagLine() 0 8 2
A getCollectionId() 0 8 2
1
<?php
2
3
namespace vfalies\tmdb\Items;
4
5
class Movie extends Item implements \vfalies\tmdb\Interfaces\MovieInterface
6
{
7
    /**
8
     * Constructor
9
     * @param \vfalies\tmdb\Tmdb $tmdb
10
     * @param int $movie_id
11
     * @param array $options
12
     * @throws Exception
13
     */
14 28
    public function __construct(\vfalies\tmdb\Tmdb $tmdb, int $movie_id, array $options = array())
15
    {
16 28
        parent::__construct($tmdb, $movie_id, $options, 'movie');
17 27
    }
18
19
    /**
20
     * Get movie genres
21
     * @return array
22
     */
23 2
    public function getGenres(): array
24
    {
25 2
        if (isset($this->data->genres))
26
        {
27 1
            return $this->data->genres;
28
        }
29 1
        return [];
30
    }
31
32
    /**
33
     * Get movie title
34
     * @return string
35
     */
36 2
    public function getTitle(): string
37
    {
38 2
        if (isset($this->data->title))
39
        {
40 1
            return $this->data->title;
41
        }
42 1
        return '';
43
    }
44
45
    /**
46
     * Get movie overview
47
     * @return string
48
     */
49 2
    public function getOverview(): string
50
    {
51 2
        if (isset($this->data->overview))
52
        {
53 1
            return $this->data->overview;
54
        }
55 1
        return '';
56
    }
57
58
    /**
59
     * Get movie release date
60
     * @return string
61
     */
62 2
    public function getReleaseDate(): string
63
    {
64 2
        if (isset($this->data->release_date))
65
        {
66 1
            return $this->data->release_date;
67
        }
68 1
        return '';
69
    }
70
71
    /**
72
     * Get movie original title
73
     * @return string
74
     */
75 2
    public function getOriginalTitle(): string
76
    {
77 2
        if (isset($this->data->original_title))
78
        {
79 1
            return $this->data->original_title;
80
        }
81 1
        return '';
82
    }
83
84
    /**
85
     * Get movie note
86
     * @return float
87
     */
88 2
    public function getNote(): float
89
    {
90 2
        if (isset($this->data->vote_average))
91
        {
92 1
            return $this->data->vote_average;
93
        }
94 1
        return 0;
95
    }
96
97
    /**
98
     * Get movie id
99
     * @return int
100
     */
101 1
    public function getId(): int
102
    {
103 1
        return $this->id;
104
    }
105
106
    /**
107
     * Get IMDB movie id
108
     * @return string
109
     */
110 2
    public function getIMDBId(): string
111
    {
112 2
        if (isset($this->data->imdb_id))
113
        {
114 1
            return $this->data->imdb_id;
115
        }
116 1
        return '';
117
    }
118
119
    /**
120
     * Get movie tagline
121
     * @return string
122
     */
123 2
    public function getTagLine(): string
124
    {
125 2
        if (isset($this->data->tagline))
126
        {
127 1
            return $this->data->tagline;
128
        }
129 1
        return '';
130
    }
131
132
    /**
133
     * Get collection id
134
     * @return int
135
     */
136 2
    public function getCollectionId(): int
137
    {
138 2
        if (!empty($this->data->belongs_to_collection))
139
        {
140 1
            return (int) $this->data->belongs_to_collection->id;
141
        }
142 1
        return 0;
143
    }
144
145
}
146