Completed
Push — issue/87 ( bbd942...1f15a7 )
by Alex
06:53
created

Link   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 8 2
A createElement() 0 7 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\Rule\Atom;
12
13
use FeedIo\Feed\NodeInterface;
14
use FeedIo\RuleAbstract;
15
16
class Link extends RuleAbstract
17
{
18
19
    const NODE_NAME = 'link';
20
21
    /**
22
     * @param  NodeInterface $node
23
     * @param  \DOMElement   $element
24
     * @return mixed
25
     */
26 4
    public function setProperty(NodeInterface $node, \DOMElement $element)
27
    {
28 4
        if ($element->hasAttribute('href')) {
29 4
            $node->setLink($element->getAttribute('href'));
30 4
        }
31
32 4
        return $this;
33
    }
34
35
    /**
36
     * creates the accurate DomElement content according to the $item's property
37
     *
38
     * @param  \DomDocument  $document
39
     * @param  NodeInterface $node
40
     * @return \DomElement
41
     */
42 3
    public function createElement(\DomDocument $document, NodeInterface $node)
43
    {
44 3
        $element = $document->createElement(static::NODE_NAME);
45 3
        $element->setAttribute('href', $node->getLink());
46
47 3
        return $element;
48
    }
49
}
50