|
1
|
|
|
<?php declare(strict_types = 1); |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Tmdb package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Vincent Faliès <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
* |
|
10
|
|
|
* @author Vincent Faliès <[email protected]> |
|
11
|
|
|
* @copyright Copyright (c) 2017-2020 |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
namespace VfacTmdb\Results; |
|
16
|
|
|
|
|
17
|
|
|
use VfacTmdb\Abstracts\Results; |
|
18
|
|
|
use VfacTmdb\Interfaces\TmdbInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class to manipulate a logo result |
|
22
|
|
|
* @package Tmdb |
|
23
|
|
|
* @author Steve Richter <[email protected]> |
|
24
|
|
|
* @copyright Copyright (c) 2017-2020 |
|
25
|
|
|
*/ |
|
26
|
|
|
class Logo extends Results |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Id |
|
30
|
|
|
* @var int |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $id; |
|
33
|
|
|
/** |
|
34
|
|
|
* Id |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $logo_id; |
|
38
|
|
|
/** |
|
39
|
|
|
* Aspect ratio |
|
40
|
|
|
* @var float |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $aspect_ratio; |
|
43
|
|
|
/** |
|
44
|
|
|
* Logo file path |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $file_path; |
|
48
|
|
|
/** |
|
49
|
|
|
* Height |
|
50
|
|
|
* @var int |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $height; |
|
53
|
|
|
/** |
|
54
|
|
|
* Original file type |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $file_type; |
|
58
|
|
|
/** |
|
59
|
|
|
* Vote Average |
|
60
|
|
|
* @var float |
|
61
|
|
|
*/ |
|
62
|
|
|
protected $vote_average; |
|
63
|
|
|
/** |
|
64
|
|
|
* Vote count |
|
65
|
|
|
* @var int |
|
66
|
|
|
*/ |
|
67
|
|
|
protected $vote_count; |
|
68
|
|
|
/** |
|
69
|
|
|
* Width |
|
70
|
|
|
* @var int |
|
71
|
|
|
*/ |
|
72
|
|
|
protected $width; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Constructor |
|
76
|
|
|
* @param TmdbInterface $tmdb |
|
77
|
|
|
* @param int $id |
|
78
|
|
|
* @param \stdClass $result |
|
79
|
|
|
*/ |
|
80
|
39 |
|
public function __construct(TmdbInterface $tmdb, int $id, \stdClass $result) |
|
81
|
|
|
{ |
|
82
|
39 |
|
$result->logo_id = $result->id; |
|
83
|
39 |
|
$result->id = $id; |
|
84
|
39 |
|
parent::__construct($tmdb, $result); |
|
85
|
|
|
|
|
86
|
36 |
|
$this->id = $result->id; |
|
87
|
36 |
|
$this->logo_id = $result->logo_id; |
|
88
|
36 |
|
$this->aspect_ratio = $result->aspect_ratio; |
|
89
|
36 |
|
$this->file_path = $result->file_path; |
|
90
|
36 |
|
$this->height = $result->height; |
|
91
|
36 |
|
$this->file_type = $result->file_type; |
|
92
|
36 |
|
$this->vote_average = $result->vote_average; |
|
93
|
36 |
|
$this->vote_count = $result->vote_count; |
|
94
|
36 |
|
$this->width = $result->width; |
|
95
|
36 |
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Id |
|
99
|
|
|
* @return int |
|
100
|
|
|
*/ |
|
101
|
3 |
|
public function getId() : int |
|
102
|
|
|
{ |
|
103
|
3 |
|
return $this->id; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Aspect ratio |
|
108
|
|
|
* @return float |
|
109
|
|
|
*/ |
|
110
|
3 |
|
public function getAspectRatio() : float |
|
111
|
|
|
{ |
|
112
|
3 |
|
return $this->aspect_ratio; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Logo file path |
|
117
|
|
|
* @param bool $svg |
|
118
|
|
|
* @return string |
|
119
|
|
|
*/ |
|
120
|
9 |
|
public function getFilePath(bool $svg = true) : string |
|
121
|
|
|
{ |
|
122
|
9 |
|
if ($svg === true && $this->file_type === '.svg') { |
|
123
|
6 |
|
return substr($this->file_path, 0, -3) . 'svg'; |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
3 |
|
return $this->file_path; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Original file type |
|
131
|
|
|
* @return string |
|
132
|
|
|
*/ |
|
133
|
3 |
|
public function getFileType() : string |
|
134
|
|
|
{ |
|
135
|
3 |
|
return $this->file_type; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Height |
|
140
|
|
|
* @return int |
|
141
|
|
|
*/ |
|
142
|
3 |
|
public function getHeight() : int |
|
143
|
|
|
{ |
|
144
|
3 |
|
return $this->height; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* Id |
|
149
|
|
|
* @return string |
|
150
|
|
|
*/ |
|
151
|
3 |
|
public function getLogoId() : string |
|
152
|
|
|
{ |
|
153
|
3 |
|
return $this->logo_id; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Vote average |
|
158
|
|
|
* @return float |
|
159
|
|
|
*/ |
|
160
|
3 |
|
public function getVoteAverage() : float |
|
161
|
|
|
{ |
|
162
|
3 |
|
return $this->vote_average; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
/** |
|
166
|
|
|
* Vote count |
|
167
|
|
|
* @return int |
|
168
|
|
|
*/ |
|
169
|
3 |
|
public function getVoteCount() : int |
|
170
|
|
|
{ |
|
171
|
3 |
|
return $this->vote_count; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
/** |
|
175
|
|
|
* Width |
|
176
|
|
|
* @return int |
|
177
|
|
|
*/ |
|
178
|
3 |
|
public function getWidth() : int |
|
179
|
|
|
{ |
|
180
|
3 |
|
return $this->width; |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
|