Completed
Pull Request — project/php-7 (#133)
by Alex
04:04 queued 01:49
created

PublicId::hasValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
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
     * @return mixed
21
     */
22 5
    public function setProperty(NodeInterface $node, \DOMElement $element)
23
    {
24 5
        $node->setPublicId($element->nodeValue);
25
26 5
        return $node;
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32 3
    protected function hasValue(NodeInterface $node) : bool
33
    {
34 3
        return !! $node->getPublicId();
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40 3
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
41
    {
42 3
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getPublicId()));
43 3
    }
44
}
45