Completed
Push — issue/72 ( 085764 )
by Alex
18:17
created

Item::addMedia()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
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;
12
13
use FeedIo\Feed\Item\Media;
14
use FeedIo\Feed\Item\MediaInterface;
15
use FeedIo\Feed\Item\Author;
16
use FeedIo\Feed\Item\AuthorInterface;
17
18
class Item extends Node implements ItemInterface
19
{
20
21
    /**
22
     * @var \ArrayIterator
23
     */
24
    protected $medias;
25
26
    /**
27
     * @var AuthorInterface
28
     */
29
    protected $author;
30
31 72
    public function __construct()
32
    {
33 72
        $this->medias = new \ArrayIterator();
34
35 72
        parent::__construct();
36 72
    }
37
38
    /**
39
     * @param  MediaInterface $media
40
     * @return $this
41
     */
42 8
    public function addMedia(MediaInterface $media)
43
    {
44 8
        $this->medias->append($media);
45
46 8
        return $this;
47
    }
48
49
    /**
50
     * @return \ArrayIterator
51
     */
52 7
    public function getMedias()
53
    {
54 7
        return $this->medias;
55
    }
56
57
    /**
58
     * @return boolean
59
     */
60 5
    public function hasMedia()
61
    {
62 5
        return $this->medias->count() > 0;
63
    }
64
65
    /**
66
     * @return MediaInterface
67
     */
68 5
    public function newMedia()
69
    {
70 5
        return new Media();
71
    }
72
73
    /**
74
     * @return AuthorInterface
75
     */
76 7
    public function getAuthor()
77
    {
78 7
        return $this->author;
79
    }
80
81
    /**
82
     * @param  AuthorInterface $author
83
     * @return $this
84
     */
85 8
    public function setAuthor(AuthorInterface $author)
86
    {
87 8
        $this->author = $author;
88
89 8
        return $this;
90
    }
91
92
    /**
93
     * @return AuthorInterface
94
     */
95 6
    public function newAuthor()
96
    {
97 6
        return new Author();
98
    }
99
}
100