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

TVSeason   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 16
lcom 1
cbo 2
dl 0
loc 74
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
    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