1: <?php
2: namespace Duyplus\TMDBApi\Classes\Data;
3:
4: use Duyplus\TMDBApi\Classes\Data\Movie;
5:
6: class Company
7: {
8: //------------------------------------------------------------------------------
9: // Class Variables
10: //------------------------------------------------------------------------------
11:
12: private $crawl;
13:
14: /**
15: * Construct Class
16: *
17: * @param array $data An array with the data of the Company
18: */
19: public function __construct($data)
20: {
21: $this->crawl = $data;
22: }
23:
24: //------------------------------------------------------------------------------
25: // Get Variables
26: //------------------------------------------------------------------------------
27:
28: /**
29: * Get the Company's id
30: *
31: * @return int
32: */
33: public function getID()
34: {
35: return $this->crawl['id'];
36: }
37:
38: /**
39: * Get the Company's name
40: *
41: * @return string
42: */
43: public function getName()
44: {
45: return $this->crawl['name'];
46: }
47:
48: /**
49: * Get the Company's description
50: *
51: * @return string
52: */
53: public function getDescription()
54: {
55: return $this->crawl['description'];
56: }
57:
58: /**
59: * Get the Company's headquarters
60: *
61: * @return string
62: */
63: public function getHeadquarters()
64: {
65: return $this->crawl['headquarters'];
66: }
67:
68: /**
69: * Get the Company's logo
70: *
71: * @return string
72: */
73: public function getLogo()
74: {
75: return $this->crawl['logo_path'];
76: }
77:
78: /**
79: * Get the Company's homepage
80: *
81: * @return string
82: */
83: public function getHomepage()
84: {
85: return $this->crawl['homepage'];
86: }
87:
88: /**
89: * Get the Company's movies
90: *
91: * @return Movie[]
92: */
93: public function getMovies()
94: {
95: if (!isset($this->crawl['movies']['results'])) {
96: return [];
97: }
98:
99: $movies = [];
100:
101: foreach ($this->crawl['movies']['results'] as $data) {
102: $movies[] = new Movie($data);
103: }
104:
105: return $movies;
106: }
107:
108: /**
109: * Get Generic.<br>
110: * Get a item of the array, you should not get used to use this, better use specific get's.
111: *
112: * @param string $item The item of the $data array you want
113: * @return array|mixed|null Returns the entire data array, a specific item, or null if the item does not exist.
114: */
115: public function get($item = '')
116: {
117: if (empty($item)) {
118: return $this->crawl;
119: }
120: if (array_key_exists($item, $this->crawl)) {
121: return $this->crawl[$item];
122: }
123: return null;
124: }
125:
126: /**
127: * Get the JSON representation of the Company
128: *
129: * @return string
130: */
131: public function getJSON()
132: {
133: return json_encode($this->crawl, JSON_PRETTY_PRINT);
134: }
135: }