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