Completed
Push — ruudvdd-fetch-subtags-issue-76 ( 94f122 )
by Alex
03:52
created

Element   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A setName() 0 6 1
A getValue() 0 4 1
A setValue() 0 6 1
A getAttribute() 0 8 2
A getAttributes() 0 4 1
A setAttribute() 0 6 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\Node;
12
13
use FeedIo\Feed\ElementsAwareTrait;
14
15
class Element implements ElementInterface
16
{
17
    use ElementsAwareTrait;
18
19
    /**
20
     * @var string
21
     */
22
    protected $name;
23
24
    /**
25
     * @var string
26
     */
27
    protected $value;
28
29
    /**
30
     * @var array
31
     */
32
    protected $attributes = array();
33
34 32
    public function __construct()
35
    {
36 32
        $this->initElements();
37 32
    }
38
39
    /**
40
     * @return string
41
     */
42 23
    public function getName()
43
    {
44 23
        return $this->name;
45
    }
46
47
    /**
48
     * @param  string $name
49
     * @return $this
50
     */
51 28
    public function setName($name)
52
    {
53 28
        $this->name = $name;
54
55 28
        return $this;
56
    }
57
58
    /**
59
     * @return string
60
     */
61 14
    public function getValue()
62
    {
63 14
        return $this->value;
64
    }
65
66
    /**
67
     * @param  string $value
68
     * @return $this
69
     */
70 23
    public function setValue($value)
71
    {
72 23
        $this->value = $value;
73
74 23
        return $this;
75
    }
76
77
    /**
78
     * @param  string $name
79
     * @return string
80
     */
81 3
    public function getAttribute($name)
82
    {
83 3
        if (array_key_exists($name, $this->attributes)) {
84 2
            return $this->attributes[$name];
85
        }
86
87 1
        return;
88
    }
89
90
    /**
91
     * @return array
92
     */
93 6
    public function getAttributes()
94
    {
95 6
        return $this->attributes;
96
    }
97
98
    /**
99
     * @param  string $name
100
     * @param  string $value
101
     * @return $this
102
     */
103 5
    public function setAttribute($name, $value)
104
    {
105 5
        $this->attributes[$name] = $value;
106
107 5
        return $this;
108
    }
109
}
110