1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace MovingImage\Client\VMPro\Entity; |
6
|
|
|
|
7
|
|
|
use DateTime; |
8
|
|
|
use JMS\Serializer\Annotation\Type; |
9
|
|
|
use JMS\Serializer\Annotation\SerializedName; |
10
|
|
|
use MovingImage\Meta\Interfaces\VideoInterface; |
11
|
|
|
|
12
|
|
|
class Video implements VideoInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @Type("string") |
16
|
|
|
*/ |
17
|
|
|
private $id; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @Type("string") |
21
|
|
|
*/ |
22
|
|
|
private $title; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @Type("string") |
26
|
|
|
*/ |
27
|
|
|
private $description; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @Type("string") |
31
|
|
|
*/ |
32
|
|
|
private $thumbnail; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @Type("integer") |
36
|
|
|
*/ |
37
|
|
|
private $length; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @Type("integer") |
41
|
|
|
* @SerializedName("createdDate") |
42
|
|
|
*/ |
43
|
|
|
private $createdDate; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @Type("integer") |
47
|
|
|
* @SerializedName("modifiedDate") |
48
|
|
|
*/ |
49
|
|
|
private $modifiedDate; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @Type("integer") |
53
|
|
|
* @SerializedName("uploadDate") |
54
|
|
|
*/ |
55
|
|
|
private $uploadDate; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @Type("integer") |
59
|
|
|
*/ |
60
|
|
|
private $generation; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @Type("integer") |
64
|
|
|
*/ |
65
|
|
|
private $plays; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @Type("integer") |
69
|
|
|
*/ |
70
|
|
|
private $views; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @Type("boolean") |
74
|
|
|
* @SerializedName("allFormatsAvailable") |
75
|
|
|
*/ |
76
|
|
|
private $allFormatsAvailable; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @TODO replace it with array collection |
80
|
|
|
* |
81
|
|
|
* @Type("array") |
82
|
|
|
* @SerializedName("customMetadata") |
83
|
|
|
*/ |
84
|
|
|
private $customMetadata; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @TODO replace it with array collection |
88
|
|
|
* |
89
|
|
|
* @Type("array") |
90
|
|
|
*/ |
91
|
|
|
private $keywords; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @TODO replace it with array collection |
95
|
|
|
* |
96
|
|
|
* @Type("array") |
97
|
|
|
*/ |
98
|
|
|
private $stills; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @Type("boolean") |
102
|
|
|
*/ |
103
|
|
|
private $published; |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @Type("array") |
107
|
|
|
*/ |
108
|
|
|
private $channels; |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @Type("string") |
112
|
|
|
* @SerializedName("uploadFileName") |
113
|
|
|
*/ |
114
|
|
|
private $uploadFileName; |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @Type("boolean") |
118
|
|
|
*/ |
119
|
|
|
private $downloadable; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @Type("MovingImage\Client\VMPro\Entity\CorporateTubeMetaData") |
123
|
|
|
* @SerializedName("corporateTubeMetadata") |
124
|
|
|
*/ |
125
|
|
|
private $corporateTubeMetadata; |
126
|
|
|
|
127
|
|
|
public function setId(string $id): self |
128
|
|
|
{ |
129
|
|
|
$this->id = $id; |
130
|
|
|
|
131
|
|
|
return $this; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function getId(): string |
135
|
|
|
{ |
136
|
|
|
return $this->id; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
public function getTitle(): ?string |
140
|
|
|
{ |
141
|
|
|
return $this->title; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
public function setTitle(string $title): self |
145
|
|
|
{ |
146
|
|
|
$this->title = $title; |
147
|
|
|
|
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
public function getDescription(): ?string |
152
|
|
|
{ |
153
|
|
|
return $this->description; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function setDescription(string $description): self |
157
|
|
|
{ |
158
|
|
|
$this->description = $description; |
159
|
|
|
|
160
|
|
|
return $this; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
public function getThumbnail(): ?string |
164
|
|
|
{ |
165
|
|
|
return $this->thumbnail; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
public function setThumbnail(string $thumbnail): self |
169
|
|
|
{ |
170
|
|
|
$this->thumbnail = $thumbnail; |
171
|
|
|
|
172
|
|
|
return $this; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function getLength(): ?int |
176
|
|
|
{ |
177
|
|
|
return $this->length; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
public function setLength(int $length): self |
181
|
|
|
{ |
182
|
|
|
$this->length = $length; |
183
|
|
|
|
184
|
|
|
return $this; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function getCreatedDate(): DateTime |
188
|
|
|
{ |
189
|
|
|
$date = new DateTime(); |
190
|
|
|
$date->setTimestamp(intval($this->createdDate / 1000)); |
191
|
|
|
|
192
|
|
|
return $date; |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function setCreatedDate(DateTime $createdDate): Video |
196
|
|
|
{ |
197
|
|
|
$this->createdDate = $createdDate->getTimestamp() * 1000; |
198
|
|
|
|
199
|
|
|
return $this; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function getModifiedDate(): ?DateTime |
203
|
|
|
{ |
204
|
|
|
$date = new DateTime(); |
205
|
|
|
$date->setTimestamp(intval($this->modifiedDate / 1000)); |
206
|
|
|
|
207
|
|
|
return $date; |
208
|
|
|
} |
209
|
|
|
|
210
|
|
|
public function setModifiedDate(DateTime $modifiedDate): self |
211
|
|
|
{ |
212
|
|
|
$this->modifiedDate = $modifiedDate->getTimestamp() * 1000; |
213
|
|
|
|
214
|
|
|
return $this; |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function getUploadDate(): ?DateTime |
218
|
|
|
{ |
219
|
|
|
$date = new DateTime(); |
220
|
|
|
$date->setTimestamp(intval($this->uploadDate / 1000)); |
221
|
|
|
|
222
|
|
|
return $date; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
public function setUploadDate(DateTime $uploadDate): self |
226
|
|
|
{ |
227
|
|
|
$this->uploadDate = $uploadDate->getTimestamp() * 1000; |
228
|
|
|
|
229
|
|
|
return $this; |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
public function getGeneration(): ?int |
233
|
|
|
{ |
234
|
|
|
return $this->generation; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
public function setGeneration(int $generation): self |
238
|
|
|
{ |
239
|
|
|
$this->generation = $generation; |
240
|
|
|
|
241
|
|
|
return $this; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
public function getPlays(): int |
245
|
|
|
{ |
246
|
|
|
if (!$this->plays) { |
247
|
|
|
return 0; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
return $this->plays; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
public function setPlays(int $plays): self |
254
|
|
|
{ |
255
|
|
|
$this->plays = $plays; |
256
|
|
|
|
257
|
|
|
return $this; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
public function getViews(): int |
261
|
|
|
{ |
262
|
|
|
if (!$this->views) { |
263
|
|
|
return 0; |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
return $this->views; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function setViews(int $views): self |
270
|
|
|
{ |
271
|
|
|
$this->views = $views; |
272
|
|
|
|
273
|
|
|
return $this; |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
public function areAllFormatsAvailable(): bool |
277
|
|
|
{ |
278
|
|
|
if (!$this->allFormatsAvailable) { |
279
|
|
|
return false; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
return $this->allFormatsAvailable; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
public function setAllFormatsAvailable(bool $allFormatsAvailable): self |
286
|
|
|
{ |
287
|
|
|
$this->allFormatsAvailable = $allFormatsAvailable; |
288
|
|
|
|
289
|
|
|
return $this; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
public function getCustomMetadata(): array |
293
|
|
|
{ |
294
|
|
|
if (!$this->customMetadata) { |
295
|
|
|
return []; |
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
return $this->customMetadata; |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
public function setCustomMetadata(array $customMetadata): self |
302
|
|
|
{ |
303
|
|
|
$this->customMetadata = $customMetadata; |
304
|
|
|
|
305
|
|
|
return $this; |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
public function getKeywords(): array |
309
|
|
|
{ |
310
|
|
|
if (!$this->keywords) { |
311
|
|
|
return []; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
return $this->keywords; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
public function setKeywords(array $keywords): self |
318
|
|
|
{ |
319
|
|
|
$this->keywords = $keywords; |
320
|
|
|
|
321
|
|
|
return $this; |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
public function getStills(): array |
325
|
|
|
{ |
326
|
|
|
if (!$this->stills) { |
327
|
|
|
return []; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
//sorting preview's images from smallest to biggest |
331
|
|
|
usort($this->stills, function (array $item1, array $item2) { |
332
|
|
|
if (isset($item1['dimension']['height'], $item2['dimension']['height']) && $item1['dimension']['height'] != $item2['dimension']['height']) { |
333
|
|
|
return ($item1['dimension']['height'] > $item2['dimension']['height']) ? 1 : -1; |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
return 0; |
337
|
|
|
}); |
338
|
|
|
|
339
|
|
|
return $this->stills; |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
public function setStills(array $stills): self |
343
|
|
|
{ |
344
|
|
|
$this->stills = $stills; |
345
|
|
|
|
346
|
|
|
return $this; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
public function setPublished(bool $published): self |
350
|
|
|
{ |
351
|
|
|
$this->published = $published; |
352
|
|
|
|
353
|
|
|
return $this; |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
public function isPublished(): bool |
357
|
|
|
{ |
358
|
|
|
if (!$this->published) { |
359
|
|
|
return false; |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
return $this->published; |
363
|
|
|
} |
364
|
|
|
|
365
|
|
|
public function setDownloadable(bool $downloadable): self |
366
|
|
|
{ |
367
|
|
|
$this->downloadable = $downloadable; |
368
|
|
|
|
369
|
|
|
return $this; |
370
|
|
|
} |
371
|
|
|
|
372
|
|
|
public function isDownloadable(): bool |
373
|
|
|
{ |
374
|
|
|
if (!$this->downloadable) { |
375
|
|
|
return false; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
return $this->downloadable; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
public function getStatus(): int |
382
|
|
|
{ |
383
|
|
|
return $this->isPublished() |
384
|
|
|
? VideoInterface::STATUS_PUBLISHED |
385
|
|
|
: VideoInterface::STATUS_NOT_PUBLISHED; |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
public function getChannels(): array |
389
|
|
|
{ |
390
|
|
|
if (!$this->channels) { |
391
|
|
|
return []; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
|
395
|
|
|
return $this->channels; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
public function setChannels(array $channels): self |
399
|
|
|
{ |
400
|
|
|
$this->channels = $channels; |
401
|
|
|
|
402
|
|
|
return $this; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
public function getUploadFileName(): string |
406
|
|
|
{ |
407
|
|
|
if (!$this->uploadFileName) { |
408
|
|
|
return ''; |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
return $this->uploadFileName; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
public function setUploadFileName(string $uploadFileName): self |
415
|
|
|
{ |
416
|
|
|
$this->uploadFileName = $uploadFileName; |
417
|
|
|
|
418
|
|
|
return $this; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
public function setCorporateTubeMetadata(CorporateTubeMetaData $corporateTubeMetadata): self |
422
|
|
|
{ |
423
|
|
|
$this->corporateTubeMetadata = $corporateTubeMetadata; |
424
|
|
|
|
425
|
|
|
return $this; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
public function getCorporateTubeMetadata(): ?CorporateTubeMetaData |
429
|
|
|
{ |
430
|
|
|
return $this->corporateTubeMetadata; |
431
|
|
|
} |
432
|
|
|
} |
433
|
|
|
|