Logo   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 35
loc 35
ccs 10
cts 11
cp 0.9091
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 6 6 2
A hasValue() 4 4 2
A addElement() 7 7 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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