Passed
Push — master ( 74d4a8...9f17d2 )
by
unknown
01:31
created

TVSeason   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 2
dl 0
loc 74
ccs 33
cts 33
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 7 2
A getAirDate() 0 7 2
A getEpisodeCount() 0 7 2
A getSeasonNumber() 0 7 2
A getEpisodes() 0 9 3
A getName() 0 7 2
A getOverview() 0 7 2
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 24
    public function __construct(Tmdb $tmdb, int $tv_id, int $season_number, array $options = array())
21
    {
22 24
        parent::__construct($tmdb, $season_number, $options, 'tv/'.$tv_id);
23 24
    }
24
25 2
    public function getId(): int
26
    {
27 2
        if (! empty($this->data->id)) {
28 1
            return (int) $this->data->id;
29
        }
30 1
        return 0;
31
    }
32
33 2
    public function getAirDate(): string
34
    {
35 2
        if (! empty($this->data->air_date)) {
36 1
            return $this->data->air_date;
37
        }
38 1
        return '';
39
    }
40
41 2
    public function getEpisodeCount(): int
42
    {
43 2
        if (! empty($this->data->episodes)) {
44 1
            return count($this->data->episodes);
45
        }
46 1
        return 0;
47
    }
48
49 2
    public function getSeasonNumber(): int
50
    {
51 2
        if (! empty($this->data->season_number)) {
52 1
            return (int) $this->data->season_number;
53
        }
54 1
        return 0;
55
    }
56
57 12
    public function getEpisodes(): \Generator
58
    {
59 12
        if (! empty($this->data->episodes)) {
60 11
            foreach ($this->data->episodes as $episode) {
61 11
                $episode = new \vfalies\tmdb\Results\TVEpisode($this->tmdb, $episode);
62 11
                yield $episode;
63
            }
64
        }
65 1
    }
66
67 2
    public function getName(): string
68
    {
69 2
        if (! empty($this->data->name)) {
70 1
            return $this->data->name;
71
        }
72 1
        return '';
73
    }
74
75 2
    public function getOverview(): string
76
    {
77 2
        if (! empty($this->data->overview)) {
78 1
            return $this->data->overview;
79
        }
80 1
        return '';
81
    }
82
}
83