Completed
Pull Request — master (#257)
by
unknown
01:57
created

Link::setProperty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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