Video::getCategory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Thepixeldeveloper\Sitemap\Subelements;
4
5
use XMLWriter;
6
use Thepixeldeveloper\Sitemap\OutputInterface;
7
use Thepixeldeveloper\Sitemap\AppendAttributeInterface;
8
9
/**
10
 * Class Video
11
 *
12
 * @package Thepixeldeveloper\Sitemap\Subelements
13
 */
14
class Video implements OutputInterface, AppendAttributeInterface
15
{
16
    /**
17
     * URL pointing to an image thumbnail.
18
     *
19
     * @var string
20
     */
21
    protected $thumbnailLoc;
22
23
    /**
24
     * Title of the video, max 100 characters.
25
     *
26
     * @var string
27
     */
28
    protected $title;
29
30
    /**
31
     * Description of the video, max 2048 characters.
32
     *
33
     * @var string
34
     */
35
    protected $description;
36
37
    /**
38
     * URL pointing to the actual media file (mp4).
39
     *
40
     * @var string
41
     */
42
    protected $contentLoc;
43
44
    /**
45
     * URL pointing to the player file (normally a SWF).
46
     *
47
     * @var string
48
     */
49
    protected $playerLoc;
50
51
    /**
52
     * Indicates whether the video is live.
53
     *
54
     * @var boolean
55
     */
56
    protected $live;
57
58
    /**
59
     * Duration of the video in seconds.
60
     *
61
     * @var integer
62
     */
63
    protected $duration;
64
65
    /**
66
     * String of space delimited platform values.
67
     *
68
     * Allowed values are web, mobile, and tv.
69
     *
70
     * @var string
71
     */
72
    protected $platform;
73
74
    /**
75
     * Does the video require a subscription?
76
     *
77
     * @var boolean
78
     */
79
    protected $requiresSubscription;
80
81
    /**
82
     * The price to download or view the video in ISO 4217 format.
83
     *
84
     * @link http://en.wikipedia.org/wiki/ISO_4217
85
     *
86
     * @var string
87
     */
88
    protected $price;
89
90
    /**
91
     * Link to gallery of which this video appears in.
92
     *
93
     * @var string
94
     */
95
    protected $galleryLoc;
96
97
    /**
98
     * A space-delimited list of countries where the video may or may not be played.
99
     *
100
     * @var string
101
     */
102
    protected $restriction;
103
104
    /**
105
     * A tag associated with the video.
106
     *
107
     * @var array
108
     */
109
    protected $tags = [];
110
111
    /**
112
     * The video's category. For example, cooking.
113
     *
114
     * @var string
115
     */
116
    protected $category;
117
118
    /**
119
     * No if the video should be available only to users with SafeSearch turned off.
120
     *
121
     * @var string
122
     */
123
    protected $familyFriendly;
124
125
    /**
126
     * The date the video was first published, in W3C format.
127
     *
128
     * @var string
129
     */
130
    protected $publicationDate;
131
132
    /**
133
     * The number of times the video has been viewed.
134
     *
135
     * @var integer
136
     */
137
    protected $viewCount;
138
139
    /**
140
     * The video uploader's name. Only one <video:uploader> is allowed per video.
141
     *
142
     * @var string
143
     */
144
    protected $uploader;
145
146
    /**
147
     * The rating of the video. Allowed values are float numbers in the range 0.0 to 5.0.
148
     *
149
     * @var float
150
     */
151
    protected $rating;
152
153
    /**
154
     * The date after which the video will no longer be available, in W3C format.
155
     *
156
     * @var string
157
     */
158
    protected $expirationDate;
159
160
    /**
161
     * Video constructor.
162
     *
163
     * @param string $thumbnailLoc
164
     * @param string $title
165
     * @param string $description
166
     */
167
    public function __construct($thumbnailLoc, $title, $description)
168
    {
169
        $this->thumbnailLoc = $thumbnailLoc;
170
        $this->title        = $title;
171
        $this->description  = $description;
172
    }
173
174
    /**
175
     * URL pointing to the player file (normally a SWF).
176
     *
177
     * @return string
178
     */
179
    public function getPlayerLoc()
180
    {
181
        return $this->playerLoc;
182
    }
183
184
    /**
185
     * URL pointing to the player file (normally a SWF).
186
     *
187
     * @param string $playerLoc
188
     *
189
     * @return $this
190
     */
191
    public function setPlayerLoc($playerLoc)
192
    {
193
        $this->playerLoc = $playerLoc;
194
195
        return $this;
196
    }
197
198
    /**
199
     * {@inheritdoc}
200
     */
201
    public function generateXML(XMLWriter $XMLWriter)
202
    {
203
        $XMLWriter->startElement('video:video');
204
205
        $XMLWriter->writeElement('video:thumbnail_loc', $this->getThumbnailLoc());
206
        $XMLWriter->writeElement('video:title', $this->getTitle());
207
        $XMLWriter->writeElement('video:description', $this->getDescription());
208
209
        $this->optionalWriteElement($XMLWriter, 'video:content_loc', $this->getContentLoc());
210
        $this->optionalWriteElement($XMLWriter, 'video:player_loc', $this->getPlayerLoc());
211
        $this->optionalWriteElement($XMLWriter, 'video:duration', $this->getDuration());
212
        $this->optionalWriteElement($XMLWriter, 'video:expiration_date', $this->getExpirationDate());
213
        $this->optionalWriteElement($XMLWriter, 'video:rating', $this->getRating());
214
        $this->optionalWriteElement($XMLWriter, 'video:view_count', $this->getViewCount());
215
        $this->optionalWriteElement($XMLWriter, 'video:publication_date', $this->getPublicationDate());
216
        $this->optionalWriteElement($XMLWriter, 'video:family_friendly', $this->getFamilyFriendly());
217
218
        foreach ($this->getTags() as $tag) {
219
            $this->optionalWriteElement($XMLWriter, 'video:tag', $tag);
220
        }
221
222
        $this->optionalWriteElement($XMLWriter, 'video:category', $this->getCategory());
223
        $this->optionalWriteElement($XMLWriter, 'video:restriction', $this->getRestriction());
224
        $this->optionalWriteElement($XMLWriter, 'video:gallery_loc', $this->getGalleryLoc());
225
        $this->optionalWriteElement($XMLWriter, 'video:price', $this->getPrice());
226
        $this->optionalWriteElement($XMLWriter, 'video:requires_subscription', $this->getRequiresSubscription());
227
        $this->optionalWriteElement($XMLWriter, 'video:uploader', $this->getUploader());
228
        $this->optionalWriteElement($XMLWriter, 'video:platform', $this->getPlatform());
229
        $this->optionalWriteElement($XMLWriter, 'video:live', $this->getLive());
230
231
        $XMLWriter->endElement();
232
    }
233
234
    /**
235
     * URL pointing to an image thumbnail.
236
     *
237
     * @return string
238
     */
239
    public function getThumbnailLoc()
240
    {
241
        return $this->thumbnailLoc;
242
    }
243
244
    /**
245
     * Title of the video, max 100 characters.
246
     *
247
     * @return string
248
     */
249
    public function getTitle()
250
    {
251
        return $this->title;
252
    }
253
254
    /**
255
     * Description of the video, max 2048 characters.
256
     *
257
     * @return string
258
     */
259
    public function getDescription()
260
    {
261
        return $this->description;
262
    }
263
264
    /**
265
     * {@inheritdoc}
266
     */
267
    protected function optionalWriteElement(XMLWriter $XMLWriter, $name, $value)
268
    {
269
        if ($value) {
270
            $XMLWriter->writeElement($name, $value);
271
        }
272
    }
273
274
    /**
275
     * URL pointing to the actual media file (mp4).
276
     *
277
     * @return string
278
     */
279
    public function getContentLoc()
280
    {
281
        return $this->contentLoc;
282
    }
283
284
    /**
285
     * URL pointing to the actual media file (mp4).
286
     *
287
     * @param string $contentLoc
288
     *
289
     * @return $this
290
     */
291
    public function setContentLoc($contentLoc)
292
    {
293
        $this->contentLoc = $contentLoc;
294
295
        return $this;
296
    }
297
298
    /**
299
     * Duration of the video in seconds.
300
     *
301
     * @return integer
302
     */
303
    public function getDuration()
304
    {
305
        return $this->duration;
306
    }
307
308
    /**
309
     * Duration of the video in seconds.
310
     *
311
     * @param integer $duration
312
     *
313
     * @return $this
314
     */
315
    public function setDuration($duration)
316
    {
317
        $this->duration = $duration;
318
319
        return $this;
320
    }
321
322
    /**
323
     * The date after which the video will no longer be available, in W3C format.
324
     *
325
     * @return string
326
     */
327
    public function getExpirationDate()
328
    {
329
        return $this->expirationDate;
330
    }
331
332
    /**
333
     * The date after which the video will no longer be available, in W3C format.
334
     *
335
     * @param string $expirationDate
336
     *
337
     * @return $this
338
     */
339
    public function setExpirationDate($expirationDate)
340
    {
341
        $this->expirationDate = $expirationDate;
342
343
        return $this;
344
    }
345
346
    /**
347
     * The rating of the video. Allowed values are float numbers in the range 0.0 to 5.0.
348
     *
349
     * @return float
350
     */
351
    public function getRating()
352
    {
353
        return $this->rating;
354
    }
355
356
    /**
357
     * The rating of the video. Allowed values are float numbers in the range 0.0 to 5.0.
358
     *
359
     * @param float $rating
360
     *
361
     * @return $this
362
     */
363
    public function setRating($rating)
364
    {
365
        $this->rating = $rating;
366
367
        return $this;
368
    }
369
370
    /**
371
     * The number of times the video has been viewed.
372
     *
373
     * @return integer
374
     */
375
    public function getViewCount()
376
    {
377
        return $this->viewCount;
378
    }
379
380
    /**
381
     * The number of times the video has been viewed.
382
     *
383
     * @param integer $viewCount
384
     *
385
     * @return $this
386
     */
387
    public function setViewCount($viewCount)
388
    {
389
        $this->viewCount = $viewCount;
390
391
        return $this;
392
    }
393
394
    /**
395
     * The date the video was first published, in W3C format.
396
     *
397
     * @return string
398
     */
399
    public function getPublicationDate()
400
    {
401
        return $this->publicationDate;
402
    }
403
404
    /**
405
     * The date the video was first published, in W3C format.
406
     *
407
     * @param string $publicationDate
408
     *
409
     * @return $this
410
     */
411
    public function setPublicationDate($publicationDate)
412
    {
413
        $this->publicationDate = $publicationDate;
414
415
        return $this;
416
    }
417
418
    /**
419
     * No if the video should be available only to users with SafeSearch turned off.
420
     *
421
     * @return string
422
     */
423
    public function getFamilyFriendly()
424
    {
425
        return $this->familyFriendly;
426
    }
427
428
    /**
429
     * No if the video should be available only to users with SafeSearch turned off.
430
     *
431
     * @param string $familyFriendly
432
     *
433
     * @return $this
434
     */
435
    public function setFamilyFriendly($familyFriendly)
436
    {
437
        $this->familyFriendly = $familyFriendly;
438
439
        return $this;
440
    }
441
442
    /**
443
     * A tag associated with the video.
444
     *
445
     * @return array
446
     */
447
    public function getTags()
448
    {
449
        return $this->tags;
450
    }
451
452
    /**
453
     * A tag associated with the video.
454
     *
455
     * @param array $tags
456
     *
457
     * @return $this
458
     */
459
    public function setTags($tags)
460
    {
461
        $this->tags = $tags;
462
463
        return $this;
464
    }
465
466
    /**
467
     * The video's category. For example, cooking.
468
     *
469
     * @return string
470
     */
471
    public function getCategory()
472
    {
473
        return $this->category;
474
    }
475
476
    /**
477
     * The video's category. For example, cooking.
478
     *
479
     * @param string $category
480
     *
481
     * @return $this
482
     */
483
    public function setCategory($category)
484
    {
485
        $this->category = $category;
486
487
        return $this;
488
    }
489
490
    /**
491
     * A space-delimited list of countries where the video may or may not be played.
492
     *
493
     * @return string
494
     */
495
    public function getRestriction()
496
    {
497
        return $this->restriction;
498
    }
499
500
    /**
501
     * A space-delimited list of countries where the video may or may not be played.
502
     *
503
     * @param string $restriction
504
     *
505
     * @return $this
506
     */
507
    public function setRestriction($restriction)
508
    {
509
        $this->restriction = $restriction;
510
511
        return $this;
512
    }
513
514
    /**
515
     * Link to gallery of which this video appears in.
516
     *
517
     * @return string
518
     */
519
    public function getGalleryLoc()
520
    {
521
        return $this->galleryLoc;
522
    }
523
524
    /**
525
     * Link to gallery of which this video appears in.
526
     *
527
     * @param string $galleryLoc
528
     *
529
     * @return $this
530
     */
531
    public function setGalleryLoc($galleryLoc)
532
    {
533
        $this->galleryLoc = $galleryLoc;
534
535
        return $this;
536
    }
537
538
    /**
539
     * The price to download or view the video in ISO 4217 format.
540
     *
541
     * @return string
542
     */
543
    public function getPrice()
544
    {
545
        return $this->price;
546
    }
547
548
    /**
549
     * The price to download or view the video in ISO 4217 format.
550
     *
551
     * @param string $price
552
     *
553
     * @return $this
554
     */
555
    public function setPrice($price)
556
    {
557
        $this->price = $price;
558
559
        return $this;
560
    }
561
562
    /**
563
     * Does the video require a subscription?
564
     *
565
     * @return boolean
566
     */
567
    public function getRequiresSubscription()
568
    {
569
        return $this->requiresSubscription;
570
    }
571
572
    /**
573
     * Does the video require a subscription?
574
     *
575
     * @param boolean $requiresSubscription
576
     *
577
     * @return $this
578
     */
579
    public function setRequiresSubscription($requiresSubscription)
580
    {
581
        $this->requiresSubscription = $requiresSubscription;
582
583
        return $this;
584
    }
585
586
    /**
587
     * The video uploader's name. Only one <video:uploader> is allowed per video.
588
     *
589
     * @return string
590
     */
591
    public function getUploader()
592
    {
593
        return $this->uploader;
594
    }
595
596
    /**
597
     * The video uploader's name. Only one <video:uploader> is allowed per video.
598
     *
599
     * @param string $uploader
600
     *
601
     * @return $this
602
     */
603
    public function setUploader($uploader)
604
    {
605
        $this->uploader = $uploader;
606
607
        return $this;
608
    }
609
610
    /**
611
     * String of space delimited platform values.
612
     *
613
     * Allowed values are web, mobile, and tv.
614
     *
615
     * @return string
616
     */
617
    public function getPlatform()
618
    {
619
        return $this->platform;
620
    }
621
622
    /**
623
     * String of space delimited platform values.
624
     *
625
     * Allowed values are web, mobile, and tv.
626
     *
627
     * @param string $platform
628
     *
629
     * @return $this
630
     */
631
    public function setPlatform($platform)
632
    {
633
        $this->platform = $platform;
634
635
        return $this;
636
    }
637
638
    /**
639
     * Indicates whether the video is live.
640
     *
641
     * @return boolean
642
     */
643
    public function getLive()
644
    {
645
        return $this->live;
646
    }
647
648
    /**
649
     * Indicates whether the video is live.
650
     *
651
     * @param boolean $live
652
     *
653
     * @return $this
654
     */
655
    public function setLive($live)
656
    {
657
        $this->live = $live;
658
659
        return $this;
660
    }
661
662
    /**
663
     * {@inheritdoc}
664
     */
665
    public function appendAttributeToCollectionXML(XMLWriter $XMLWriter)
666
    {
667
        $XMLWriter->writeAttribute('xmlns:video', 'http://www.google.com/schemas/sitemap-video/1.1');
668
    }
669
}
670