Completed
Pull Request — master (#257)
by Éloi
02:14
created

MediaConstant   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 10
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromXML() 0 4 2
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
abstract class MediaConstant
14
{
15
    /**
16
     * @param string|null $value
17
     */
18 47
    public static function fromXML(?string $value) : ?int
19
    {
20 47
        return static::VALUES[$value ? strtolower($value) : $value] ?? null;
21
    }
22
}
23
24
abstract class MediaDescriptionType extends MediaConstant
25
{
26
    const Plain = 1;
27
    const HTML = 2;
28
29
    const VALUES = array(
30
        null => MediaDescriptionType::Plain,
31
        "plain" => MediaDescriptionType::Plain,
32
        "html" => MediaDescriptionType::HTML,
33
    );
34
}
35
36
abstract class MediaTitleType extends MediaConstant
37
{
38
    const Plain = 1;
39
    const HTML = 2;
40
41
    const VALUES = array(
42
        null => MediaTitleType::Plain,
43
        "plain" => MediaTitleType::Plain,
44
        "html" => MediaTitleType::HTML,
45
    );
46
}
47
48
49
class Media implements MediaInterface
50
{
51
    /**
52
     * @var string
53
     */
54
    protected $nodeName;
55
56
    /**
57
     * @var string
58
     */
59
    protected $type;
60
61
    /**
62
     * @var string
63
     */
64
    protected $url;
65
66
    /**
67
     * @var string
68
     */
69
    protected $length;
70
71
    /**
72
     * @var string
73
     */
74
    protected $title;
75
76
    /**
77
     * @var string
78
     */
79
    protected $description;
80
81
    /**
82
     * @var string
83
     */
84
    protected $rights;
85
86
    /**
87
     * @var int
88
     */
89
    protected $titleType;
90
91
    /**
92
     * @var int
93
     */
94
    protected $descriptionType;
95
96
    /**
97
     * @var array
98
     */
99
    protected $keywords = array();
100
101
    /**
102
     * @var array
103
     */
104
    protected $comments = array();
105
106
    /**
107
     * @var array
108
     */
109
    protected $responses = array();
110
111
    /**
112
     * @var array
113
     */
114
    protected $backlinks = array();
115
116
    /**
117
     * @var array
118
     */
119
    protected $credits = array();
120
121
    /**
122
     * @var array
123
     */
124
    protected $texts = array();
125
126
    /**
127
     * @var array
128
     */
129
    protected $prices = array();
130
131
    /**
132
     * @var array
133
     */
134
    protected $subTitles = array();
135
136
    /**
137
     * @var array
138
     */
139
    protected $scenes = array();
140
141
    /**
142
     * @var MediaContentInterface
143
     */
144
    protected $content;
145
146
    /**
147
     * @var MediaThumbnailInterface
148
     */
149
    protected $thumbnail;
150
151
    /**
152
     * @var MediaCategoryInterface
153
     */
154
    protected $category;
155
156
    /**
157
     * @var MediaHashInterface
158
     */
159
    protected $hash;
160
161
    /**
162
     * @var MediaHashInterface
163
     */
164
    protected $embed;
165
166
    /**
167
     * @var MediaLicenseInterface
168
     */
169
    protected $license;
170
171
    /**
172
     * @var MediaCommunityInterface
173
     */
174
    protected $community;
175
176
    /**
177
     * @var MediaRestrictionInterface
178
     */
179
    protected $restriction;
180
181
    /**
182
     * @var MediaRatingInterface
183
     */
184
    protected $rating;
185
186
    /**
187
     * @var MediaCopyrightInterface
188
     */
189
    protected $copyright;
190
191
    /**
192
     * @return string
193
     */
194
    public function getNodeName() : string
195
    {
196
        return $this->nodeName;
197
    }
198
199
    /**
200
     * @param string $nodeName
201
     * @return MediaInterface
202
     */
203 51
    public function setNodeName(string $nodeName) : MediaInterface
204
    {
205 51
        $this->nodeName = $nodeName;
206
207 51
        return $this;
208
    }
209
210
    /**
211
     * @return string
212
     */
213 7
    public function getType() : ? string
214
    {
215 7
        return $this->type;
216
    }
217
218
    /**
219
     * @param  string $type
220
     * @return MediaInterface
221
     */
222 54
    public function setType(?string $type) : MediaInterface
223
    {
224 54
        $this->type = $type;
225
226 54
        return $this;
227
    }
228
229
    /**
230
     * @return string
231
     */
232 10
    public function getUrl() : ? string
233
    {
234 10
        return $this->url;
235
    }
236
237
    /**
238
     * @param  string $url
239
     * @return MediaInterface
240
     */
241 53
    public function setUrl(?string $url) : MediaInterface
242
    {
243 53
        $this->url = $url;
244
245 53
        return $this;
246
    }
247
248
    /**
249
     * @return string
250
     */
251 3
    public function getLength() : ? string
252
    {
253 3
        return $this->length;
254
    }
255
256
    /**
257
     * @param  string $length
258
     * @return MediaInterface
259
     */
260 6
    public function setLength(?string $length) : MediaInterface
261
    {
262 6
        $this->length = $length;
263
264 6
        return $this;
265
    }
266
267
    /**
268
     * @return string
269
     */
270 4
    public function getTitle() : ? string
271
    {
272 4
        return $this->title;
273
    }
274
275
    /**
276
     * @param  string $title
277
     * @return MediaInterface
278
     */
279 4
    public function setTitle(?string $title) : MediaInterface
280
    {
281 4
        $this->title = $title;
282
283 4
        return $this;
284
    }
285
286
    /**
287
     * @return string
288
     */
289 5
    public function getDescription() : ? string
290
    {
291 5
        return $this->description;
292
    }
293
294
    /**
295
     * @param  string $description
296
     * @return MediaInterface
297
     */
298 5
    public function setDescription(?string $description) : MediaInterface
299
    {
300 5
        $this->description = $description;
301
302 5
        return $this;
303
    }
304
305
    /**
306
     * @return string
307
     */
308 1
    public function getRights() : ?int
309
    {
310 1
        return $this->rights;
311
    }
312
313
    /**
314
     * @param  int $rights
315
     * @return MediaInterface
316
     */
317 1
    public function setRights(int $rights) : MediaInterface
318
    {
319 1
        $this->rights = $rights;
0 ignored issues
show
Documentation Bug introduced by
The property $rights was declared of type string, but $rights is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
320
321 1
        return $this;
322
    }
323
324
    /**
325
     * @return int
326
     */
327 2
    public function getTitleType() : ?int
328
    {
329 2
        return $this->titleType;
330
    }
331
332
    /**
333
     * @param  int $titleType
334
     * @return MediaInterface
335
     */
336 4
    public function setTitleType(?int $titleType) : MediaInterface
337
    {
338 4
        $this->titleType = $titleType;
339
340 4
        return $this;
341
    }
342
343
344
    /**
345
     * @return int
346
     */
347 2
    public function getDescriptionType() : ?int
348
    {
349 2
        return $this->descriptionType;
350
    }
351
352
    /**
353
     * @param  int $descriptionType
354
     * @return MediaInterface
355
     */
356 5
    public function setDescriptionType(?int $descriptionType) : MediaInterface
357
    {
358 5
        $this->descriptionType = $descriptionType;
359
360 5
        return $this;
361
    }
362
363
    /**
364
     * @return array
365
     */
366 1
    public function getKeywords() : array
367
    {
368 1
        return $this->keywords;
369
    }
370
371
    /**
372
     * @param  array $keywords
373
     * @return MediaInterface
374
     */
375 1
    public function setKeywords(array $keywords) : MediaInterface
376
    {
377 1
        $this->keywords = $keywords;
378
379 1
        return $this;
380
    }
381
382
    /**
383
     * @return array
384
     */
385 2
    public function getComments() : array
386
    {
387 2
        return $this->comments;
388
    }
389
390
    /**
391
     * @param  array $comments
392
     * @return MediaInterface
393
     */
394 2
    public function setComments(array $comments) : MediaInterface
395
    {
396 2
        $this->comments = $comments;
397
398 2
        return $this;
399
    }
400
401
    /**
402
     * @return array
403
     */
404 2
    public function getResponses() : array
405
    {
406 2
        return $this->responses;
407
    }
408
409
    /**
410
     * @param  array $responses
411
     * @return MediaInterface
412
     */
413 2
    public function setResponses(array $responses) : MediaInterface
414
    {
415 2
        $this->responses = $responses;
416
417 2
        return $this;
418
    }
419
420
    /**
421
     * @return array
422
     */
423 2
    public function getBacklinks() : array
424
    {
425 2
        return $this->backlinks;
426
    }
427
428
    /**
429
     * @param  array $backlinks
430
     * @return MediaInterface
431
     */
432 2
    public function setBacklinks(array $backlinks) : MediaInterface
433
    {
434 2
        $this->backlinks = $backlinks;
435
436 2
        return $this;
437
    }
438
439
    /**
440
     * @return array
441
     */
442 2
    public function getCredits() : array
443
    {
444 2
        return $this->credits;
445
    }
446
447
    /**
448
     * @param  array $credits
449
     * @return MediaInterface
450
     */
451 2
    public function setCredits(array $credits) : MediaInterface
452
    {
453 2
        $this->credits = $credits;
454
455 2
        return $this;
456
    }
457
458
    /**
459
     * @return array
460
     */
461 2
    public function getTexts() : array
462
    {
463 2
        return $this->texts;
464
    }
465
466
    /**
467
     * @param  array $texts
468
     * @return MediaInterface
469
     */
470 2
    public function setTexts(array $texts) : MediaInterface
471
    {
472 2
        $this->texts = $texts;
473
474 2
        return $this;
475
    }
476
477
    /**
478
     * @return array
479
     */
480 2
    public function getPrices() : array
481
    {
482 2
        return $this->prices;
483
    }
484
485
    /**
486
     * @param  array $prices
487
     * @return MediaInterface
488
     */
489 2
    public function setPrices(array $prices) : MediaInterface
490
    {
491 2
        $this->prices = $prices;
492
493 2
        return $this;
494
    }
495
496
    /**
497
     * @return array
498
     */
499 1
    public function getSubTitles() : array
500
    {
501 1
        return $this->subTitles;
502
    }
503
504
    /**
505
     * @param  array $subTitles
506
     * @return MediaInterface
507
     */
508 1
    public function setSubTitles(array $subTitles) : MediaInterface
509
    {
510 1
        $this->subTitles = $subTitles;
511
512 1
        return $this;
513
    }
514
515
    /**
516
     * @return array
517
     */
518 1
    public function getScenes() : array
519
    {
520 1
        return $this->scenes;
521
    }
522
523
    /**
524
     * @param  array $scenes
525
     * @return MediaInterface
526
     */
527 1
    public function setScenes(array $scenes) : MediaInterface
528
    {
529 1
        $this->scenes = $scenes;
530
531 1
        return $this;
532
    }
533
534
    /**
535
     * @return MediaContentInterface
536
     */
537 2
    public function getContent() : MediaContentInterface
538
    {
539 2
        return $this->content;
540
    }
541
542
    /**
543
     * @param  MediaContentInterface $content
544
     * @return MediaInterface
545
     */
546 47
    public function setContent(MediaContentInterface $content) : MediaInterface
547
    {
548 47
        $this->content = $content;
549
550 47
        return $this;
551
    }
552
553
    /**
554
     * @return MediaThumbnailInterface
555
     */
556 3
    public function getThumbnail() : MediaThumbnailInterface
557
    {
558 3
        return $this->thumbnail;
559
    }
560
561
    /**
562
     * @param  MediaThumbnailInterface $thumbnail
563
     * @return MediaInterface
564
     */
565 3
    public function setThumbnail(MediaThumbnailInterface $thumbnail) : MediaInterface
566
    {
567 3
        $this->thumbnail = $thumbnail;
568
569 3
        return $this;
570
    }
571
572
    /**
573
     * @return MediaCategoryInterface
574
     */
575 2
    public function getCategory() : MediaCategoryInterface
576
    {
577 2
        return $this->category;
578
    }
579
580
    /**
581
     * @param  MediaCategoryInterface $category
582
     * @return MediaInterface
583
     */
584 2
    public function setCategory(MediaCategoryInterface $category) : MediaInterface
585
    {
586 2
        $this->category = $category;
587
588 2
        return $this;
589
    }
590
591
    /**
592
     * @return MediaPlayerInterface
593
     */
594 2
    public function getPlayer() : MediaPlayerInterface
595
    {
596 2
        return $this->player;
0 ignored issues
show
Bug introduced by
The property player does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
597
    }
598
599
    /**
600
     * @param  MediaPlayerInterface $player
601
     * @return MediaInterface
602
     */
603 2
    public function setPlayer(MediaPlayerInterface $player) : MediaInterface
604
    {
605 2
        $this->player = $player;
606
607 2
        return $this;
608
    }
609
610
    /**
611
     * @return MediaHashInterface
612
     */
613 2
    public function getHash() : MediaHashInterface
614
    {
615 2
        return $this->hash;
616
    }
617
618
    /**
619
     * @param  MediaHashInterface $hash
620
     * @return MediaInterface
621
     */
622 2
    public function setHash(MediaHashInterface $hash) : MediaInterface
623
    {
624 2
        $this->hash = $hash;
625
626 2
        return $this;
627
    }
628
629
    /**
630
     * @return MediaEmbedInterface
631
     */
632 2
    public function getEmbed() : MediaEmbedInterface
633
    {
634 2
        return $this->embed;
635
    }
636
637
    /**
638
     * @param  MediaEmbedInterface $embed
639
     * @return MediaInterface
640
     */
641 2
    public function setEmbed(MediaEmbedInterface $embed) : MediaInterface
642
    {
643 2
        $this->embed = $embed;
0 ignored issues
show
Documentation Bug introduced by
It seems like $embed of type object<FeedIo\Feed\Item\MediaEmbedInterface> is incompatible with the declared type object<FeedIo\Feed\Item\MediaHashInterface> of property $embed.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
644
645 2
        return $this;
646
    }
647
648
    /**
649
     * @return MediaLicenseInterface
650
     */
651 1
    public function getLicense() : MediaLicenseInterface
652
    {
653 1
        return $this->license;
654
    }
655
656
    /**
657
     * @param  MediaLicenseInterface $license
658
     * @return MediaInterface
659
     */
660 1
    public function setLicense(MediaLicenseInterface $license) : MediaInterface
661
    {
662 1
        $this->license = $license;
663
664 1
        return $this;
665
    }
666
667
    /**
668
     * @return MediaCommunityInterface
669
     */
670 2
    public function getCommunity() : MediaCommunityInterface
671
    {
672 2
        return $this->community;
673
    }
674
675
    /**
676
     * @param  MediaCommunityInterface $community
677
     * @return MediaInterface
678
     */
679 3
    public function setCommunity(MediaCommunityInterface $community) : MediaInterface
680
    {
681 3
        $this->community = $community;
682
683 3
        return $this;
684
    }
685
686
    /**
687
     * @return MediaRestrictionInterface
688
     */
689 2
    public function getRestriction() : MediaRestrictionInterface
690
    {
691 2
        return $this->restriction;
692
    }
693
694
    /**
695
     * @param  MediaRestrictionInterface $restriction
696
     * @return MediaInterface
697
     */
698 2
    public function setRestriction(MediaRestrictionInterface $restriction) : MediaInterface
699
    {
700 2
        $this->restriction = $restriction;
701
702 2
        return $this;
703
    }
704
705
    /**
706
     * @return MediaRatingInterface
707
     */
708 2
    public function getRating() : MediaRatingInterface
709
    {
710 2
        return $this->rating;
711
    }
712
713
    /**
714
     * @param  MediaRatingInterface $rating
715
     * @return MediaInterface
716
     */
717 2
    public function setRating(MediaRatingInterface $rating) : MediaInterface
718
    {
719 2
        $this->rating = $rating;
720
721 2
        return $this;
722
    }
723
724
    /**
725
     * @return MediaCopyrightInterface
726
     */
727 2
    public function getCopyright() : MediaCopyrightInterface
728
    {
729 2
        return $this->copyright;
730
    }
731
732
    /**
733
     * @param  MediaCopyrightInterface $copyright
734
     * @return MediaInterface
735
     */
736 2
    public function setCopyright(MediaCopyrightInterface $copyright) : MediaInterface
737
    {
738 2
        $this->copyright = $copyright;
739
740 2
        return $this;
741
    }
742
743
    /**
744
     * @return MediaStatusInterface
745
     */
746 2
    public function getStatus() : MediaStatusInterface
747
    {
748 2
        return $this->status;
0 ignored issues
show
Bug introduced by
The property status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
749
    }
750
751
    /**
752
     * @param  MediaStatusInterface $status
753
     * @return MediaInterface
754
     */
755 2
    public function setStatus(MediaStatusInterface $status) : MediaInterface
756
    {
757 2
        $this->status = $status;
758
759 2
        return $this;
760
    }
761
762
    /**
763
     * @return MediaPeerLinkInterface
764
     */
765 1
    public function getPeerLink() : MediaPeerLinkInterface
766
    {
767 1
        return $this->peerLink;
0 ignored issues
show
Bug introduced by
The property peerLink does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
768
    }
769
770
    /**
771
     * @param  MediaPeerLinkInterface $peerLink
772
     * @return MediaInterface
773
     */
774 1
    public function setPeerLink(MediaPeerLinkInterface $peerLink) : MediaInterface
775
    {
776 1
        $this->peerLink = $peerLink;
777
778 1
        return $this;
779
    }
780
}
781