PublicId   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 4 4 1
A hasValue() 4 4 1
A addElement() 4 4 1

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
 * Created by PhpStorm.
4
 * User: alex
5
 * Date: 22/11/14
6
 * Time: 11:24
7
 */
8
namespace FeedIo\Rule;
9
10
use FeedIo\Feed\NodeInterface;
11
use FeedIo\RuleAbstract;
12
13 View Code Duplication
class PublicId 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...
14
{
15
    const NODE_NAME = 'guid';
16
17
    /**
18
     * @param  NodeInterface $node
19
     * @param  \DOMElement   $element
20
     */
21 10
    public function setProperty(NodeInterface $node, \DOMElement $element) : void
22
    {
23 10
        $node->setPublicId($element->nodeValue);
24 10
    }
25
26
    /**
27
     * @inheritDoc
28
     */
29 6
    protected function hasValue(NodeInterface $node) : bool
30
    {
31 6
        return !! $node->getPublicId();
32
    }
33
34
    /**
35
     * @inheritDoc
36
     */
37 3
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
38
    {
39 3
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getPublicId()));
40 3
    }
41
}
42