Completed
Pull Request — project/php-7 (#133)
by Alex
04:04 queued 01:49
created

Link   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 8 2
A addElement() 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\Rule\Link as BaseLink;
15
16
class Link extends BaseLink
17
{
18
    const NODE_NAME = 'link';
19
20
    /**
21
     * @param  NodeInterface $node
22
     * @param  \DOMElement   $element
23
     * @return mixed
24
     */
25 4
    public function setProperty(NodeInterface $node, \DOMElement $element)
26
    {
27 4
        if ($element->hasAttribute('href')) {
28 4
            $node->setLink($element->getAttribute('href'));
29
        }
30
31 4
        return $this;
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37 3
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
38
    {
39 3
        $element = $document->createElement(static::NODE_NAME);
40 3
        $element->setAttribute('href', $node->getLink());
41
42 3
        $rootElement->appendChild($element);
43 3
    }
44
}
45