Completed
Pull Request — master (#257)
by Éloi
01:56
created

Media::getRestriction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[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
11
namespace FeedIo\Feed\Item;
12
13
use FeedIo\Feed\ArrayableInterface;
14
15
abstract class MediaConstant
16
{
17
    /**
18
     * @param string|null $value
19
     */
20 47
    public static function fromXML(?string $value) : ?int
21
    {
22 47
        return static::VALUES[$value ? strtolower($value) : $value] ?? null;
23
    }
24
}
25
26
abstract class MediaDescriptionType extends MediaConstant
27
{
28
    const Plain = 1;
29
    const HTML = 2;
30
31
    const VALUES = array(
32
        null => MediaDescriptionType::Plain,
33
        "plain" => MediaDescriptionType::Plain,
34
        "html" => MediaDescriptionType::HTML,
35
    );
36
}
37
38
abstract class MediaTitleType extends MediaConstant
39
{
40
    const Plain = 1;
41
    const HTML = 2;
42
43
    const VALUES = array(
44
        null => MediaTitleType::Plain,
45
        "plain" => MediaTitleType::Plain,
46
        "html" => MediaTitleType::HTML,
47
    );
48
}
49
50
51
class Media implements MediaInterface, ArrayableInterface
52
{
53
    /**
54
     * @var string
55
     */
56
    protected $nodeName;
57
58
    /**
59
     * @var string
60
     */
61
    protected $type;
62
63
    /**
64
     * @var string
65
     */
66
    protected $url;
67
68
    /**
69
     * @var string
70
     */
71
    protected $length;
72
73
    /**
74
     * @var string
75
     */
76
    protected $title;
77
78
    /**
79
     * @var string
80
     */
81
    protected $description;
82
83
    /**
84
     * @var int
85
     */
86
    protected $rights;
87
88
    /**
89
     * @var int
90
     */
91
    protected $titleType;
92
93
    /**
94
     * @var int
95
     */
96
    protected $descriptionType;
97
98
    /**
99
     * @var array
100
     */
101
    protected $keywords = array();
102
103
    /**
104
     * @var array
105
     */
106
    protected $comments = array();
107
108
    /**
109
     * @var array
110
     */
111
    protected $responses = array();
112
113
    /**
114
     * @var array
115
     */
116
    protected $backlinks = array();
117
118
    /**
119
     * @var array
120
     */
121
    protected $credits = array();
122
123
    /**
124
     * @var array
125
     */
126
    protected $texts = array();
127
128
    /**
129
     * @var array
130
     */
131
    protected $prices = array();
132
133
    /**
134
     * @var array
135
     */
136
    protected $subTitles = array();
137
138
    /**
139
     * @var array
140
     */
141
    protected $scenes = array();
142
143
    /**
144
     * @var MediaContentInterface
145
     */
146
    protected $content;
147
148
    /**
149
     * @var MediaThumbnailInterface
150
     */
151
    protected $thumbnail;
152
153
    /**
154
     * @var MediaCategoryInterface
155
     */
156
    protected $category;
157
158
    /**
159
     * @var MediaHashInterface
160
     */
161
    protected $hash;
162
163
    /**
164
     * @var MediaEmbedInterface
165
     */
166
    protected $embed;
167
168
    /**
169
     * @var MediaLicenseInterface
170
     */
171
    protected $license;
172
173
    /**
174
     * @var MediaCommunityInterface
175
     */
176
    protected $community;
177
178
    /**
179
     * @var MediaRestrictionInterface
180
     */
181
    protected $restriction;
182
183
    /**
184
     * @var MediaRatingInterface
185
     */
186
    protected $rating;
187
188
    /**
189
     * @var MediaCopyrightInterface
190
     */
191
    protected $copyright;
192
193
    /**
194
     * @var MediaPlayerInterface
195
     */
196
    protected $player;
197
198
    /**
199
     * @var MediaStatusInterface
200
     */
201
    protected $status;
202
203
    /**
204
     * @var MediaPeerLinkInterface
205
     */
206
    protected $peerLink;
207
208
    /**
209
     * @return string
210
     */
211
    public function getNodeName() : string
212
    {
213
        return $this->nodeName;
214
    }
215
216
    /**
217
     * @param string $nodeName
218
     * @return MediaInterface
219
     */
220 51
    public function setNodeName(string $nodeName) : MediaInterface
221
    {
222 51
        $this->nodeName = $nodeName;
223
224 51
        return $this;
225
    }
226
227
    /**
228
     * @return string
229
     */
230 7
    public function getType() : ? string
231
    {
232 7
        return $this->type;
233
    }
234
235
    /**
236
     * @param  string $type
237
     * @return MediaInterface
238
     */
239 55
    public function setType(?string $type) : MediaInterface
240
    {
241 55
        $this->type = $type;
242
243 55
        return $this;
244
    }
245
246
    /**
247
     * @return string
248
     */
249 10
    public function getUrl() : ? string
250
    {
251 10
        return $this->url;
252
    }
253
254
    /**
255
     * @param  string $url
256
     * @return MediaInterface
257
     */
258 54
    public function setUrl(?string $url) : MediaInterface
259
    {
260 54
        $this->url = $url;
261
262 54
        return $this;
263
    }
264
265
    /**
266
     * @return string
267
     */
268 3
    public function getLength() : ? string
269
    {
270 3
        return $this->length;
271
    }
272
273
    /**
274
     * @param  string $length
275
     * @return MediaInterface
276
     */
277 6
    public function setLength(?string $length) : MediaInterface
278
    {
279 6
        $this->length = $length;
280
281 6
        return $this;
282
    }
283
284
    /**
285
     * @return string
286
     */
287 4
    public function getTitle() : ? string
288
    {
289 4
        return $this->title;
290
    }
291
292
    /**
293
     * @param  string $title
294
     * @return MediaInterface
295
     */
296 5
    public function setTitle(?string $title) : MediaInterface
297
    {
298 5
        $this->title = $title;
299
300 5
        return $this;
301
    }
302
303
    /**
304
     * @return string
305
     */
306 5
    public function getDescription() : ? string
307
    {
308 5
        return $this->description;
309
    }
310
311
    /**
312
     * @param  string $description
313
     * @return MediaInterface
314
     */
315 5
    public function setDescription(?string $description) : MediaInterface
316
    {
317 5
        $this->description = $description;
318
319 5
        return $this;
320
    }
321
322
    /**
323
     * @return string
324
     */
325 1
    public function getRights() : ?int
326
    {
327 1
        return $this->rights;
328
    }
329
330
    /**
331
     * @param  int $rights
332
     * @return MediaInterface
333
     */
334 1
    public function setRights(int $rights) : MediaInterface
335
    {
336 1
        $this->rights = $rights;
337
338 1
        return $this;
339
    }
340
341
    /**
342
     * @return int
343
     */
344 2
    public function getTitleType() : ?int
345
    {
346 2
        return $this->titleType;
347
    }
348
349
    /**
350
     * @param  int $titleType
351
     * @return MediaInterface
352
     */
353 4
    public function setTitleType(?int $titleType) : MediaInterface
354
    {
355 4
        $this->titleType = $titleType;
356
357 4
        return $this;
358
    }
359
360
361
    /**
362
     * @return int
363
     */
364 2
    public function getDescriptionType() : ?int
365
    {
366 2
        return $this->descriptionType;
367
    }
368
369
    /**
370
     * @param  int $descriptionType
371
     * @return MediaInterface
372
     */
373 5
    public function setDescriptionType(?int $descriptionType) : MediaInterface
374
    {
375 5
        $this->descriptionType = $descriptionType;
376
377 5
        return $this;
378
    }
379
380
    /**
381
     * @return array
382
     */
383 1
    public function getKeywords() : array
384
    {
385 1
        return $this->keywords;
386
    }
387
388
    /**
389
     * @param  array $keywords
390
     * @return MediaInterface
391
     */
392 1
    public function setKeywords(array $keywords) : MediaInterface
393
    {
394 1
        $this->keywords = $keywords;
395
396 1
        return $this;
397
    }
398
399
    /**
400
     * @return array
401
     */
402 2
    public function getComments() : array
403
    {
404 2
        return $this->comments;
405
    }
406
407
    /**
408
     * @param  array $comments
409
     * @return MediaInterface
410
     */
411 2
    public function setComments(array $comments) : MediaInterface
412
    {
413 2
        $this->comments = $comments;
414
415 2
        return $this;
416
    }
417
418
    /**
419
     * @return array
420
     */
421 2
    public function getResponses() : array
422
    {
423 2
        return $this->responses;
424
    }
425
426
    /**
427
     * @param  array $responses
428
     * @return MediaInterface
429
     */
430 2
    public function setResponses(array $responses) : MediaInterface
431
    {
432 2
        $this->responses = $responses;
433
434 2
        return $this;
435
    }
436
437
    /**
438
     * @return array
439
     */
440 2
    public function getBacklinks() : array
441
    {
442 2
        return $this->backlinks;
443
    }
444
445
    /**
446
     * @param  array $backlinks
447
     * @return MediaInterface
448
     */
449 2
    public function setBacklinks(array $backlinks) : MediaInterface
450
    {
451 2
        $this->backlinks = $backlinks;
452
453 2
        return $this;
454
    }
455
456
    /**
457
     * @return array
458
     */
459 2
    public function getCredits() : array
460
    {
461 2
        return $this->credits;
462
    }
463
464
    /**
465
     * @param  array $credits
466
     * @return MediaInterface
467
     */
468 2
    public function setCredits(array $credits) : MediaInterface
469
    {
470 2
        $this->credits = $credits;
471
472 2
        return $this;
473
    }
474
475
    /**
476
     * @return array
477
     */
478 2
    public function getTexts() : array
479
    {
480 2
        return $this->texts;
481
    }
482
483
    /**
484
     * @param  array $texts
485
     * @return MediaInterface
486
     */
487 2
    public function setTexts(array $texts) : MediaInterface
488
    {
489 2
        $this->texts = $texts;
490
491 2
        return $this;
492
    }
493
494
    /**
495
     * @return array
496
     */
497 2
    public function getPrices() : array
498
    {
499 2
        return $this->prices;
500
    }
501
502
    /**
503
     * @param  array $prices
504
     * @return MediaInterface
505
     */
506 2
    public function setPrices(array $prices) : MediaInterface
507
    {
508 2
        $this->prices = $prices;
509
510 2
        return $this;
511
    }
512
513
    /**
514
     * @return array
515
     */
516 1
    public function getSubTitles() : array
517
    {
518 1
        return $this->subTitles;
519
    }
520
521
    /**
522
     * @param  array $subTitles
523
     * @return MediaInterface
524
     */
525 1
    public function setSubTitles(array $subTitles) : MediaInterface
526
    {
527 1
        $this->subTitles = $subTitles;
528
529 1
        return $this;
530
    }
531
532
    /**
533
     * @return array
534
     */
535 1
    public function getScenes() : array
536
    {
537 1
        return $this->scenes;
538
    }
539
540
    /**
541
     * @param  array $scenes
542
     * @return MediaInterface
543
     */
544 1
    public function setScenes(array $scenes) : MediaInterface
545
    {
546 1
        $this->scenes = $scenes;
547
548 1
        return $this;
549
    }
550
551
    /**
552
     * @return MediaContentInterface
553
     */
554 2
    public function getContent() : MediaContentInterface
555
    {
556 2
        return $this->content;
557
    }
558
559
    /**
560
     * @param  MediaContentInterface $content
561
     * @return MediaInterface
562
     */
563 47
    public function setContent(MediaContentInterface $content) : MediaInterface
564
    {
565 47
        $this->content = $content;
566
567 47
        return $this;
568
    }
569
570
    /**
571
     * @return MediaThumbnailInterface
572
     */
573 3
    public function getThumbnail() : MediaThumbnailInterface
574
    {
575 3
        return $this->thumbnail;
576
    }
577
578
    /**
579
     * @param  MediaThumbnailInterface $thumbnail
580
     * @return MediaInterface
581
     */
582 3
    public function setThumbnail(MediaThumbnailInterface $thumbnail) : MediaInterface
583
    {
584 3
        $this->thumbnail = $thumbnail;
585
586 3
        return $this;
587
    }
588
589
    /**
590
     * @return array
591
     */
592 1
    public function toArray() : array
593
    {
594 1
        return get_object_vars($this);
595
    }
596
597
    /**
598
     * @return MediaCategoryInterface
599
     */
600 2
    public function getCategory() : MediaCategoryInterface
601
    {
602 2
        return $this->category;
603
    }
604
605
    /**
606
     * @param  MediaCategoryInterface $category
607
     * @return MediaInterface
608
     */
609 2
    public function setCategory(MediaCategoryInterface $category) : MediaInterface
610
    {
611 2
        $this->category = $category;
612
613 2
        return $this;
614
    }
615
616
    /**
617
     * @return MediaPlayerInterface
618
     */
619 2
    public function getPlayer() : MediaPlayerInterface
620
    {
621 2
        return $this->player;
622
    }
623
624
    /**
625
     * @param  MediaPlayerInterface $player
626
     * @return MediaInterface
627
     */
628 2
    public function setPlayer(MediaPlayerInterface $player) : MediaInterface
629
    {
630 2
        $this->player = $player;
631
632 2
        return $this;
633
    }
634
635
    /**
636
     * @return MediaHashInterface
637
     */
638 2
    public function getHash() : MediaHashInterface
639
    {
640 2
        return $this->hash;
641
    }
642
643
    /**
644
     * @param  MediaHashInterface $hash
645
     * @return MediaInterface
646
     */
647 2
    public function setHash(MediaHashInterface $hash) : MediaInterface
648
    {
649 2
        $this->hash = $hash;
650
651 2
        return $this;
652
    }
653
654
    /**
655
     * @return MediaEmbedInterface
656
     */
657 2
    public function getEmbed() : MediaEmbedInterface
658
    {
659 2
        return $this->embed;
660
    }
661
662
    /**
663
     * @param  MediaEmbedInterface $embed
664
     * @return MediaInterface
665
     */
666 2
    public function setEmbed(MediaEmbedInterface $embed) : MediaInterface
667
    {
668 2
        $this->embed = $embed;
669
670 2
        return $this;
671
    }
672
673
    /**
674
     * @return MediaLicenseInterface
675
     */
676 1
    public function getLicense() : MediaLicenseInterface
677
    {
678 1
        return $this->license;
679
    }
680
681
    /**
682
     * @param  MediaLicenseInterface $license
683
     * @return MediaInterface
684
     */
685 1
    public function setLicense(MediaLicenseInterface $license) : MediaInterface
686
    {
687 1
        $this->license = $license;
688
689 1
        return $this;
690
    }
691
692
    /**
693
     * @return MediaCommunityInterface
694
     */
695 2
    public function getCommunity() : MediaCommunityInterface
696
    {
697 2
        return $this->community;
698
    }
699
700
    /**
701
     * @param  MediaCommunityInterface $community
702
     * @return MediaInterface
703
     */
704 3
    public function setCommunity(MediaCommunityInterface $community) : MediaInterface
705
    {
706 3
        $this->community = $community;
707
708 3
        return $this;
709
    }
710
711
    /**
712
     * @return MediaRestrictionInterface
713
     */
714 2
    public function getRestriction() : MediaRestrictionInterface
715
    {
716 2
        return $this->restriction;
717
    }
718
719
    /**
720
     * @param  MediaRestrictionInterface $restriction
721
     * @return MediaInterface
722
     */
723 2
    public function setRestriction(MediaRestrictionInterface $restriction) : MediaInterface
724
    {
725 2
        $this->restriction = $restriction;
726
727 2
        return $this;
728
    }
729
730
    /**
731
     * @return MediaRatingInterface
732
     */
733 2
    public function getRating() : MediaRatingInterface
734
    {
735 2
        return $this->rating;
736
    }
737
738
    /**
739
     * @param  MediaRatingInterface $rating
740
     * @return MediaInterface
741
     */
742 2
    public function setRating(MediaRatingInterface $rating) : MediaInterface
743
    {
744 2
        $this->rating = $rating;
745
746 2
        return $this;
747
    }
748
749
    /**
750
     * @return MediaCopyrightInterface
751
     */
752 2
    public function getCopyright() : MediaCopyrightInterface
753
    {
754 2
        return $this->copyright;
755
    }
756
757
    /**
758
     * @param  MediaCopyrightInterface $copyright
759
     * @return MediaInterface
760
     */
761 2
    public function setCopyright(MediaCopyrightInterface $copyright) : MediaInterface
762
    {
763 2
        $this->copyright = $copyright;
764
765 2
        return $this;
766
    }
767
768
    /**
769
     * @return MediaStatusInterface
770
     */
771 2
    public function getStatus() : MediaStatusInterface
772
    {
773 2
        return $this->status;
774
    }
775
776
    /**
777
     * @param  MediaStatusInterface $status
778
     * @return MediaInterface
779
     */
780 2
    public function setStatus(MediaStatusInterface $status) : MediaInterface
781
    {
782 2
        $this->status = $status;
783
784 2
        return $this;
785
    }
786
787
    /**
788
     * @return MediaPeerLinkInterface
789
     */
790 1
    public function getPeerLink() : MediaPeerLinkInterface
791
    {
792 1
        return $this->peerLink;
793
    }
794
795
    /**
796
     * @param  MediaPeerLinkInterface $peerLink
797
     * @return MediaInterface
798
     */
799 1
    public function setPeerLink(MediaPeerLinkInterface $peerLink) : MediaInterface
800
    {
801 1
        $this->peerLink = $peerLink;
802
803 1
        return $this;
804
    }
805
}
806