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