Test Failed
Branch release/1.5.0 (5e38ec)
by vincent
02:28
created

TVEpisode::getCrew()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 11
Ratio 84.62 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 11
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
crap 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A TVEpisode::getEpisodeNumber() 0 8 2
1
<?php
2
3
namespace vfalies\tmdb\Items;
4
5
use vfalies\tmdb\Abstracts\Item;
6
use vfalies\tmdb\Interfaces\Items\TVEpisodeInterface;
7
use vfalies\tmdb\Tmdb;
8
use vfalies\tmdb\Exceptions\NotYetImplementedException;
9
use vfalies\tmdb\Traits\ElementTrait;
10
use vfalies\tmdb\lib\Guzzle\Client as HttpClient;
11
use vfalies\tmdb\Results\Image;
12
use vfalies\tmdb\Traits\TVEpisodeTrait;
13
14
class TVEpisode extends Item implements TVEpisodeInterface
0 ignored issues
show
Bug introduced by
There is one abstract method getCrew in this class; you could implement it, or declare this class as abstract.
Loading history...
15
{
16
17
    use ElementTrait;
18
    use TVEpisodeTrait;
19
20
    protected $season_number;
21
    protected $episode_number;
22 22
23
    public function __construct(Tmdb $tmdb, $tv_id, $season_number, $episode_number, array $options = array())
24 22
    {
25
        parent::__construct($tmdb, $episode_number, $options, 'tv/'.$tv_id.'/'.$season_number);
26 22
27 22
        $this->season_number = $season_number;
28 22
        $this->episode_number = $episode_number;
29
    }
30
31
    /**
32
     * Get TV show id
33
     * @return int
34 2
     */
35
    public function getId()
36 2
    {
37
        if (isset($this->data->id))
38 1
        {
39
            return (int) $this->data->id;
40 1
        }
41
        return 0;
42
    }
43 2
44
    public function getAirDate()
45 2
    {
46
        if (isset($this->data->air_date))
47 1
        {
48
            return $this->data->air_date;
49 1
        }
50
        return '';
51
    }
52 1
53
    public function getEpisodeNumber()
54 1
    {
55
        if (isset($this->data->episode_number))
56 1
        {
57
            return $this->data->episode_number;
58 1
        }
59
        return 0;
60 1
    }
61 1
62
    /**
63
     * @codeCoverageIgnore
64 1
     * @throws NotYetImplementedException
65
     */
66 2
    public function getGuestStars()
67
    {
68 2
        throw new NotYetImplementedException;
69
    }
70 1
71
    public function getName()
72 1
    {
73
        if (isset($this->data->name))
74
        {
75
            return $this->data->name;
76
        }
77
        return '';
78
    }
79
80
    public function getNote()
81
    {
82
        if (isset($this->data->vote_average))
83
        {
84 2
            return $this->data->vote_average;
85
        }
86 2
        return 0;
87
    }
88 1
89
    public function getNoteCount()
90 1
    {
91
        if (isset($this->data->vote_count))
92
        {
93 2
            return (int) $this->data->vote_count;
94
        }
95 2
        return 0;
96
    }
97 1
98
    public function getOverview()
99 1
    {
100
        if (isset($this->data->overview))
101
        {
102 2
            return $this->data->overview;
103
        }
104 2
        return '';
105
    }
106 1
107
    public function getProductionCode()
108 1
    {
109
        if (isset($this->data->production_code))
110
        {
111 2
            return $this->data->production_code;
112
        }
113 2
        return '';
114
    }
115 1
116
    public function getSeasonNumber()
117 1
    {
118
        if (isset($this->data->season_number))
119
        {
120 2
            return (int) $this->data->season_number;
121
        }
122 2
        return 0;
123
    }
124 1
125
    public function getStillPath()
126 1
    {
127
        if (isset($this->data->still_path))
128
        {
129 2
            return $this->data->still_path;
130
        }
131 2
        return '';
132
    }
133 1
134 View Code Duplication
    public function getPosters()
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...
135 1
    {
136
        $data = $this->tmdb->sendRequest(new HttpClient(new \GuzzleHttp\Client()), '/tv/'.(int) $this->id.'/seasons/'.$this->season_number.'/episode/'.$this->episode_number.'/images', null, $this->params);
137
138 2
        foreach ($data->posters as $b)
139
        {
140 2
            $image = new Image($this->tmdb, $this->id, $b);
141
            yield $image;
142 1
        }
143
    }
144 1
145
}
146