Completed
Push — issue/87 ( bbd942 )
by Alex
04:44
created

Link   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 55.56%

Importance

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

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 2
    public function setProperty(NodeInterface $node, \DOMElement $element)
27
    {
28 2
        if ($element->hasAttribute('href')) {
29 2
            $node->setLink($element->getAttribute('href'));
30 2
        }
31
32 2
        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
    public function createElement(\DomDocument $document, NodeInterface $node)
43
    {
44
        $element = $document->createElement(static::NODE_NAME);
45
        $element->setAttribute('href', $node->getLink());
46
47
        return $element;
48
    }
49
}
50