1: | <?php |
2: | namespace duyplus\tmdbapi\classes\data; |
3: | |
4: | use duyplus\tmdbapi\classes\data\Movie; |
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 Collection |
19: | { |
20: | //------------------------------------------------------------------------------ |
21: | // Class Variables |
22: | //------------------------------------------------------------------------------ |
23: | |
24: | private $_data; |
25: | |
26: | /** |
27: | * Construct Class |
28: | * |
29: | * @param array $data An array with the data of a Collection |
30: | */ |
31: | public function __construct($data) |
32: | { |
33: | $this->_data = $data; |
34: | } |
35: | |
36: | //------------------------------------------------------------------------------ |
37: | // Get Variables |
38: | //------------------------------------------------------------------------------ |
39: | |
40: | /** |
41: | * Get the Collection's name |
42: | * |
43: | * @return string |
44: | */ |
45: | public function getName() |
46: | { |
47: | return $this->_data['name']; |
48: | } |
49: | |
50: | /** |
51: | * Get the Collection's id |
52: | * |
53: | * @return int |
54: | */ |
55: | public function getID() |
56: | { |
57: | return $this->_data['id']; |
58: | } |
59: | |
60: | /** |
61: | * Get the Collection's overview |
62: | * |
63: | * @return string |
64: | */ |
65: | public function getOverview() |
66: | { |
67: | return $this->_data['overview']; |
68: | } |
69: | |
70: | /** |
71: | * Get the Collection's poster |
72: | * |
73: | * @return string |
74: | */ |
75: | public function getPoster() |
76: | { |
77: | return $this->_data['poster_path']; |
78: | } |
79: | |
80: | /** |
81: | * Get the Collection's backdrop |
82: | * |
83: | * @return string |
84: | */ |
85: | public function getBackdrop() |
86: | { |
87: | return $this->_data['backdrop_path']; |
88: | } |
89: | |
90: | /** |
91: | * Get the Collection's Movies |
92: | * |
93: | * @return Movie[] |
94: | */ |
95: | public function getMovies() |
96: | { |
97: | $movies = array(); |
98: | foreach ($this->_data['parts'] as $data) { |
99: | $movies[] = new Movie($data); |
100: | } |
101: | return $movies; |
102: | } |
103: | |
104: | /** |
105: | * Get Generic.<br> |
106: | * Get a item of the array, you should not get used to use this, better use specific get's. |
107: | * |
108: | * @param string $item The item of the $data array you want |
109: | * @return array |
110: | */ |
111: | public function get($item = '') |
112: | { |
113: | return (empty($item)) ? $this->_data : $this->_data[$item]; |
114: | } |
115: | } |
116: | ?> |