1: | <?php |
2: | namespace Duyplus\TMDBApi\Classes\Data; |
3: | |
4: | class Episode |
5: | { |
6: | //------------------------------------------------------------------------------ |
7: | // Class Variables |
8: | //------------------------------------------------------------------------------ |
9: | |
10: | private $crawl; |
11: | private $idTVS; |
12: | |
13: | /** |
14: | * Construct Class |
15: | * |
16: | * @param array $data An array with the data of a Episode |
17: | * @param int $idTVShow The TVShow's id |
18: | */ |
19: | public function __construct($data, $idTVShow = 0) |
20: | { |
21: | $this->crawl = $data; |
22: | $this->idTVS = $idTVShow; |
23: | } |
24: | |
25: | //------------------------------------------------------------------------------ |
26: | // Get Variables |
27: | //------------------------------------------------------------------------------ |
28: | |
29: | /** |
30: | * Get the Episode's id |
31: | * |
32: | * @return int |
33: | */ |
34: | public function getID() |
35: | { |
36: | return $this->crawl['id']; |
37: | } |
38: | |
39: | /** |
40: | * Get the Episode's name |
41: | * |
42: | * @return string |
43: | */ |
44: | public function getName() |
45: | { |
46: | return $this->crawl['name']; |
47: | } |
48: | |
49: | /** |
50: | * Get the TVShow id |
51: | * |
52: | * @return int |
53: | */ |
54: | public function getTVShowID() |
55: | { |
56: | return $this->idTVS; |
57: | } |
58: | |
59: | /** |
60: | * Get the Season's number |
61: | * |
62: | * @return int |
63: | */ |
64: | public function getSeasonNumber() |
65: | { |
66: | return $this->crawl['season_number']; |
67: | } |
68: | |
69: | /** |
70: | * Get the Episode's number |
71: | * |
72: | * @return int |
73: | */ |
74: | public function getEpisodeNumber() |
75: | { |
76: | return $this->crawl['episode_number']; |
77: | } |
78: | |
79: | /** |
80: | * Get the Episode's overview |
81: | * |
82: | * @return string |
83: | */ |
84: | public function getOverview() |
85: | { |
86: | return $this->crawl['overview']; |
87: | } |
88: | |
89: | /** |
90: | * Get the Episode's still |
91: | * |
92: | * @return string |
93: | */ |
94: | public function getStill() |
95: | { |
96: | return $this->crawl['still_path']; |
97: | } |
98: | |
99: | /** |
100: | * Get the Episode's AirDate |
101: | * |
102: | * @return string |
103: | */ |
104: | public function getAirDate() |
105: | { |
106: | return $this->crawl['air_date']; |
107: | } |
108: | |
109: | /** |
110: | * Get the Episode's vote average |
111: | * |
112: | * @return int |
113: | */ |
114: | public function getVoteAverage() |
115: | { |
116: | return $this->crawl['vote_average']; |
117: | } |
118: | |
119: | /** |
120: | * Get the Episode's vote count |
121: | * |
122: | * @return int |
123: | */ |
124: | public function getVoteCount() |
125: | { |
126: | return $this->crawl['vote_count']; |
127: | } |
128: | |
129: | /** |
130: | * Get Generic. |
131: | * Get a item of the array, you should not get used to use this, better use specific get's. |
132: | * |
133: | * @param string $item The item of the $data array you want |
134: | * @return array|mixed|null Returns the entire data array, a specific item, or null if the item does not exist. |
135: | */ |
136: | public function get($item = '') |
137: | { |
138: | if (empty($item)) { |
139: | return $this->crawl; |
140: | } |
141: | if (array_key_exists($item, $this->crawl)) { |
142: | return $this->crawl[$item]; |
143: | } |
144: | return null; |
145: | } |
146: | |
147: | /** |
148: | * Get the JSON representation of the Episode |
149: | * |
150: | * @return string |
151: | */ |
152: | public function getJSON() |
153: | { |
154: | return json_encode($this->crawl, JSON_PRETTY_PRINT); |
155: | } |
156: | } |