Passed
Branch master (465d67)
by vincent
02:35
created

TVEpisode::getCrew()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the Tmdb package.
4
 *
5
 * (c) Vincent Faliès <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Vincent Faliès <[email protected]>
11
 * @copyright Copyright (c) 2017
12
 */
13
14
15
namespace vfalies\tmdb\Results;
16
17
use vfalies\tmdb\Abstracts\Results;
18
use vfalies\tmdb\Interfaces\Results\TVEpisodeResultsInterface;
19
use vfalies\tmdb\Exceptions\NotYetImplementedException;
20
use vfalies\tmdb\Traits\ElementTrait;
21
use vfalies\tmdb\Traits\TVEpisodeTrait;
22
use vfalies\tmdb\Interfaces\TmdbInterface;
23
24
/**
25
 * Class to manipulate a TV Episode result
26
 * @package Tmdb
27
 * @author Vincent Faliès <[email protected]>
28
 * @copyright Copyright (c) 2017
29
 */
30
class TVEpisode extends Results implements TVEpisodeResultsInterface
31
{
32
33
    use ElementTrait;
34
    use TVEpisodeTrait;
35
36
    /**
37
     * Episode number
38
     * @var int
39
     */
40
    protected $episode_number = 0;
41
    /**
42
     * Name
43
     * @var string
44
     */
45
    protected $name = '';
46
    /**
47
     * Air date
48
     * @var string
49
     */
50
    protected $air_date = null;
51
    /**
52
     * Season number
53
     * @var int
54
     */
55
    protected $season_number = 0;
56
    /**
57
     * Vote average
58
     * @var float
59
     */
60
    protected $vote_average = 0;
61
    /**
62
     * Vote count
63
     * @var int
64
     */
65
    protected $vote_count = 0;
66
    /**
67
     * Overview
68
     * @var string
69
     */
70
    protected $overview = '';
71
    /**
72
     * Production code
73
     * @var string
74
     */
75
    protected $production_code = '';
76
    /**
77
     * Image still path
78
     * @var string
79
     */
80
    protected $still_path = '';
81
    /**
82
     * Id
83
     * @var int
84
     */
85
    protected $id = null;
86
    /**
87
     * Guest stars
88
     * @var array
89
     */
90
    protected $guest_stars = [];
91
92
    /**
93
     * Constructor
94
     * @param \vfalies\tmdb\Interfaces\TmdbInterface $tmdb
95
     * @param \stdClass $result
96
     * @throws \Exception
97
     */
98 20
    public function __construct(TmdbInterface $tmdb, \stdClass $result)
99
    {
100 20
        parent::__construct($tmdb, $result);
101
102
        // Populate data
103 20
        $this->id              = $this->data->id;
104 20
        $this->air_date        = $this->data->air_date;
105 20
        $this->season_number   = $this->data->season_number;
106 20
        $this->episode_number  = $this->data->episode_number;
107 20
        $this->name            = $this->data->name;
108 20
        $this->vote_average    = $this->data->vote_average;
109 20
        $this->vote_count      = $this->data->vote_count;
110 20
        $this->overview        = $this->data->overview;
111 20
        $this->production_code = $this->data->production_code;
112 20
        $this->still_path      = $this->data->still_path;
113 20
        $this->guest_stars     = $this->data->guest_stars;
114 20
    }
115
116
    /**
117
     * Air date
118
     * @return string
119
     */
120 1
    public function getAirDate()
121
    {
122 1
        return $this->air_date;
123
    }
124
125
    /**
126
     * Episode number
127
     * @return int
128
     */
129 1
    public function getEpisodeNumber()
130
    {
131 1
        return (int) $this->episode_number;
132
    }
133
134
    /**
135
     * Guests stars
136
     * @return \Generator|Results\Cast
137
     */
138 1 View Code Duplication
    public function getGuestStars()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
    {
140 1
        if (isset($this->guest_stars))
141
        {
142 1
            foreach ($this->guest_stars as $gs)
143
            {
144 1
                $gs->gender = null;
145 1
                $gs->cast_id = null;
146
147 1
                $star = new Cast($this->tmdb, $gs);
148 1
                yield $star;
149
            }
150
        }
151 1
    }
152
153
    /**
154
     * Id
155
     * @return int
156
     */
157 1
    public function getId()
158
    {
159 1
        return (int) $this->id;
160
    }
161
162
    /**
163
     * Name
164
     * @return string
165
     */
166 1
    public function getName()
167
    {
168 1
        return $this->name;
169
    }
170
171
    /**
172
     * Note
173
     * @return float
174
     */
175 1
    public function getNote()
176
    {
177 1
        return $this->vote_average;
178
    }
179
180
    /**
181
     * Note count
182
     * @return int
183
     */
184 1
    public function getNoteCount()
185
    {
186 1
        return (int) $this->vote_count;
187
    }
188
189
    /**
190
     * Overview
191
     * @return string
192
     */
193 1
    public function getOverview()
194
    {
195 1
        return $this->overview;
196
    }
197
198
    /**
199
     * Production code
200
     * @return string
201
     */
202 1
    public function getProductionCode()
203
    {
204 1
        return $this->production_code;
205
    }
206
207
    /**
208
     * Season number
209
     * @return int
210
     */
211 1
    public function getSeasonNumber()
212
    {
213 1
        return (int) $this->season_number;
214
    }
215
216
    /**
217
     * Image still path
218
     * @return string
219
     */
220 1
    public function getStillPath()
221
    {
222 1
        return $this->still_path;
223
    }
224
225
}
226