Logo::hasValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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
 * (c) Sylvain Le Gleau <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FeedIo\Rule\Atom;
13
14
use FeedIo\Feed\Item;
15
use FeedIo\Feed\Item\MediaInterface;
16
use FeedIo\Feed\ItemInterface;
17
use FeedIo\Feed\NodeInterface;
18
use FeedIo\RuleAbstract;
19
use FeedIo\FeedInterface;
20
21 View Code Duplication
class Logo extends RuleAbstract
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    // https://tools.ietf.org/html/rfc4287#section-4.2.8
24
    const NODE_NAME = 'logo';
25
26
    /**
27
     * @param  NodeInterface $node
28
     * @param  \DOMElement   $element
29
     */
30 1
    public function setProperty(NodeInterface $node, \DOMElement $element) : void
31
    {
32 1
        if ($node instanceof FeedInterface) {
33 1
            $node->setLogo($element->nodeValue);
34
        }
35 1
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 5
    protected function hasValue(NodeInterface $node) : bool
41
    {
42 5
        return $node instanceof FeedInterface && !! $node->getLogo();
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48 1
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
49
    {
50 1
        if (!($node instanceof FeedInterface) || is_null($node->getLogo())) {
51
            return;
52
        }
53 1
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getLogo()));
54 1
    }
55
}
56