1: | <?php |
2: | namespace duyplus\tmdbapi\classes\data; |
3: | |
4: | use duyplus\tmdbapi\classes\data\Season; |
5: | |
6: | /** |
7: | * This class handles all the data you can get from the api Configuration |
8: | * |
9: | * @package TMDB_V3_API_PHP |
10: | * @author Alvaro Octal |
11: | * @version 0.7 |
12: | * @date 20/01/2015 |
13: | * @updated 31/12/2024 |
14: | * @link https://github.com/duyplus/tmdbapi |
15: | * @copyright Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php) |
16: | */ |
17: | |
18: | class TVShow extends ApiBaseObject |
19: | { |
20: | //------------------------------------------------------------------------------ |
21: | // Get Variables |
22: | //------------------------------------------------------------------------------ |
23: | |
24: | /** |
25: | * Get the TVShow's name |
26: | * |
27: | * @return string |
28: | */ |
29: | public function getName() |
30: | { |
31: | return $this->_data['name']; |
32: | } |
33: | |
34: | /** |
35: | * Get the TVShow's original name |
36: | * |
37: | * @return string |
38: | */ |
39: | public function getOriginalName() |
40: | { |
41: | return $this->_data['original_name']; |
42: | } |
43: | |
44: | /** |
45: | * Get the TVShow's number of seasons |
46: | * |
47: | * @return int |
48: | */ |
49: | public function getNumSeasons() |
50: | { |
51: | return $this->_data['number_of_seasons']; |
52: | } |
53: | |
54: | /** |
55: | * Get the TVShow's number of episodes |
56: | * |
57: | * @return int |
58: | */ |
59: | public function getNumEpisodes() |
60: | { |
61: | return $this->_data['number_of_episodes']; |
62: | } |
63: | |
64: | /** |
65: | * Get a TVShow's season |
66: | * |
67: | * @param int $numSeason The season number |
68: | * @return int |
69: | */ |
70: | public function getSeason($numSeason) |
71: | { |
72: | $data = null; |
73: | |
74: | foreach ($this->_data['seasons'] as $season) { |
75: | if ($season['season_number'] == $numSeason) { |
76: | $data = $season; |
77: | break; |
78: | } |
79: | } |
80: | return new Season($data); |
81: | } |
82: | |
83: | /** |
84: | * Get the TvShow's seasons |
85: | * |
86: | * @return Season[] |
87: | */ |
88: | public function getSeasons() |
89: | { |
90: | $seasons = array(); |
91: | |
92: | foreach ($this->_data['seasons'] as $data) { |
93: | $seasons[] = new Season($data, $this->getID()); |
94: | } |
95: | |
96: | return $seasons; |
97: | } |
98: | |
99: | /** |
100: | * Get the TVShow's Backdrop |
101: | * |
102: | * @return string |
103: | */ |
104: | public function getBackdrop() |
105: | { |
106: | return $this->_data['backdrop_path']; |
107: | } |
108: | |
109: | /** |
110: | * Get the TVShow's Overview |
111: | * |
112: | * @return string |
113: | */ |
114: | public function getOverview() |
115: | { |
116: | return $this->_data['overview']; |
117: | } |
118: | |
119: | /** |
120: | * Get if the TVShow is in production |
121: | * |
122: | * @return boolean |
123: | */ |
124: | public function getInProduction() |
125: | { |
126: | return $this->_data['in_production']; |
127: | } |
128: | |
129: | //------------------------------------------------------------------------------ |
130: | // Export |
131: | //------------------------------------------------------------------------------ |
132: | |
133: | /** |
134: | * Get the JSON representation of the TVShow |
135: | * |
136: | * @return string |
137: | */ |
138: | public function getJSON() |
139: | { |
140: | return json_encode($this->_data, JSON_PRETTY_PRINT); |
141: | } |
142: | |
143: | /** |
144: | * @return string |
145: | */ |
146: | public function getMediaType() |
147: | { |
148: | return self::MEDIA_TYPE_TV; |
149: | } |
150: | } |