Completed
Push — master ( 4c7da2...64af60 )
by Alex
02:34 queued 46s
created

Link::addElement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 1
1
<?php declare(strict_types=1);
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
     */
24 5
    public function setProperty(NodeInterface $node, \DOMElement $element) : void
25
    {
26 5
        if ($element->hasAttribute('href')) {
27 5
            $node->setLink($element->getAttribute('href'));
28
        }
29 5
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 3
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
35
    {
36 3
        $element = $document->createElement(static::NODE_NAME);
37 3
        $element->setAttribute('href', $node->getLink());
38
39 3
        $rootElement->appendChild($element);
40 3
    }
41
}
42