Test Failed
Pull Request — master (#17)
by
unknown
03:56
created

TVSeason::getEpisodeCount()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace vfalies\tmdb\Items;
4
5
use vfalies\tmdb\Abstracts\Item;
6
use vfalies\tmdb\Interfaces\Items\TVSeasonInterface;
7
use vfalies\tmdb\Tmdb;
8
9
class TVSeason extends Item implements TVSeasonInterface
10
{
11
12
    /**
13
     * Constructor
14
     * @param \vfalies\tmdb\Tmdb $tmdb
15
     * @param int $tv_id
16
     * @param int $season_number
17
     * @param array $options
18
     * @throws Exception
19
     */
20
    public function __construct(Tmdb $tmdb, int $tv_id, int $season_number, array $options = array())
21
    {
22
        parent::__construct($tmdb, $season_number, $options, 'tv/'.$tv_id);
23
    }
24
25
    public function getId(): int
26
    {
27
        if (! empty($this->data->id)) {
28
            return (int) $this->data->id;
29
        }
30
        return 0;
31
    }
32
33
    public function getAirDate(): string
34
    {
35
        if (! empty($this->data->air_date)) {
36
            return $this->data->air_date;
37
        }
38
        return '';
39
    }
40
41
    public function getEpisodeCount(): int
42
    {
43
        if (! empty($this->data->episodes)) {
44
            return count($this->data->episodes);
45
        }
46
        return 0;
47
    }
48
49
    public function getSeasonNumber(): int
50
    {
51
        if (! empty($this->data->season_number)) {
52
            return (int) $this->data->season_number;
53
        }
54
        return 0;
55
    }
56
57
    public function getEpisodes(): \Generator
58
    {
59
        if (! empty($this->data->episodes)) {
60
            foreach ($this->data->episodes as $episode) {
61
                $episode = new \vfalies\tmdb\Results\TVEpisode($this->tmdb, $episode);
62
                yield $episode;
63
            }
64
        }
65
    }
66
67
    public function getName(): string
68
    {
69
        if (! empty($this->data->name)) {
70
            return $this->data->name;
71
        }
72
        return '';
73
    }
74
75
    public function getOverview(): string
76
    {
77
        if (! empty($this->data->overview)) {
78
            return $this->data->overview;
79
        }
80
        return '';
81
    }
82
}
83