1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace vfalies\tmdb\Items; |
4
|
|
|
|
5
|
|
|
use vfalies\tmdb\Abstracts\Item; |
6
|
|
|
use vfalies\tmdb\Interfaces\Items\TVShowInterface; |
7
|
|
|
use vfalies\tmdb\Tmdb; |
8
|
|
|
|
9
|
|
|
class TVShow extends Item implements TVShowInterface |
10
|
|
|
{ |
11
|
|
|
|
12
|
30 |
|
public function __construct(Tmdb $tmdb, int $tv_id, array $options = array()) |
13
|
|
|
{ |
14
|
30 |
|
parent::__construct($tmdb, $tv_id, $options, 'tv'); |
15
|
29 |
|
} |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Get TV show id |
19
|
|
|
* @return int |
20
|
|
|
*/ |
21
|
1 |
|
public function getId(): int |
22
|
|
|
{ |
23
|
1 |
|
return $this->id; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Get TVSHow genres |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
2 |
|
public function getGenres(): array |
31
|
|
|
{ |
32
|
2 |
|
if (isset($this->data->genres)) { |
33
|
1 |
|
return $this->data->genres; |
34
|
|
|
} |
35
|
1 |
|
return []; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Get TVshow note |
40
|
|
|
* @return float |
41
|
|
|
*/ |
42
|
2 |
|
public function getNote(): float |
43
|
|
|
{ |
44
|
2 |
|
if (isset($this->data->vote_average)) { |
45
|
1 |
|
return $this->data->vote_average; |
46
|
|
|
} |
47
|
1 |
|
return 0; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get TVshow number of episodes |
52
|
|
|
* @return int |
53
|
|
|
*/ |
54
|
2 |
|
public function getNumberEpisodes(): int |
55
|
|
|
{ |
56
|
2 |
|
if (isset($this->data->number_of_episodes)) { |
57
|
1 |
|
return $this->data->number_of_episodes; |
58
|
|
|
} |
59
|
1 |
|
return 0; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get TVShow number of seasons |
64
|
|
|
* @return int |
65
|
|
|
*/ |
66
|
2 |
|
public function getNumberSeasons(): int |
67
|
|
|
{ |
68
|
2 |
|
if (isset($this->data->number_of_seasons)) { |
69
|
1 |
|
return $this->data->number_of_seasons; |
70
|
|
|
} |
71
|
1 |
|
return 0; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get TVShow original title |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
2 |
|
public function getOriginalTitle(): string |
79
|
|
|
{ |
80
|
2 |
|
if (isset($this->data->original_name)) { |
81
|
1 |
|
return $this->data->original_name; |
82
|
|
|
} |
83
|
1 |
|
return ''; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get TVShow overview |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
2 |
|
public function getOverview(): string |
91
|
|
|
{ |
92
|
2 |
|
if (isset($this->data->overview)) { |
93
|
1 |
|
return $this->data->overview; |
94
|
|
|
} |
95
|
1 |
|
return ''; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Get TVShow release date |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
2 |
|
public function getReleaseDate(): string |
103
|
|
|
{ |
104
|
2 |
|
if (isset($this->data->first_air_date)) { |
105
|
1 |
|
return $this->data->first_air_date; |
106
|
|
|
} |
107
|
1 |
|
return ''; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get TVShow status |
112
|
|
|
* @return string |
113
|
|
|
*/ |
114
|
2 |
|
public function getStatus(): string |
115
|
|
|
{ |
116
|
2 |
|
if (isset($this->data->status)) { |
117
|
1 |
|
return $this->data->status; |
118
|
|
|
} |
119
|
1 |
|
return ''; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Get TVShow title |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
2 |
|
public function getTitle(): string |
127
|
|
|
{ |
128
|
2 |
|
if (isset($this->data->name)) { |
129
|
1 |
|
return $this->data->name; |
130
|
|
|
} |
131
|
1 |
|
return ''; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get TVShow seasons |
136
|
|
|
* @return \Generator |
137
|
|
|
* @throws \Exception |
138
|
|
|
*/ |
139
|
6 |
|
public function getSeasons(): \Generator |
140
|
|
|
{ |
141
|
6 |
|
if (!empty($this->data->seasons)) { |
142
|
5 |
|
foreach ($this->data->seasons as $season) { |
143
|
5 |
|
$season = new \vfalies\tmdb\Results\TVSeason($this->tmdb, $season); |
144
|
5 |
|
yield $season; |
145
|
|
|
} |
146
|
|
|
} |
147
|
1 |
|
} |
148
|
|
|
} |
149
|
|
|
|