Code Duplication    Length = 32-32 lines in 2 locations

src/FeedIo/Rule/Link.php 1 location

@@ 16-47 (lines=32) @@
13
use FeedIo\Feed\NodeInterface;
14
use FeedIo\RuleAbstract;
15
16
class Link extends RuleAbstract
17
{
18
    const NODE_NAME = 'link';
19
20
    /**
21
     * @param  NodeInterface $node
22
     * @param  \DOMElement   $element
23
     * @return mixed
24
     */
25
    public function setProperty(NodeInterface $node, \DOMElement $element)
26
    {
27
        $node->setLink($element->nodeValue);
28
29
        return $this;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    protected function hasValue(NodeInterface $node) : bool
36
    {
37
        return !! $node->getLink();
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
44
    {
45
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getLink()));
46
    }
47
}
48

src/FeedIo/Rule/PublicId.php 1 location

@@ 13-44 (lines=32) @@
10
use FeedIo\Feed\NodeInterface;
11
use FeedIo\RuleAbstract;
12
13
class PublicId extends RuleAbstract
14
{
15
    const NODE_NAME = 'guid';
16
17
    /**
18
     * @param  NodeInterface $node
19
     * @param  \DOMElement   $element
20
     * @return mixed
21
     */
22
    public function setProperty(NodeInterface $node, \DOMElement $element)
23
    {
24
        $node->setPublicId($element->nodeValue);
25
26
        return $node;
27
    }
28
29
    /**
30
     * @inheritDoc
31
     */
32
    protected function hasValue(NodeInterface $node) : bool
33
    {
34
        return !! $node->getPublicId();
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
41
    {
42
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getPublicId()));
43
    }
44
}
45