Code Duplication    Length = 35-37 lines in 2 locations

src/FeedIo/Rule/Atom/Logo.php 1 location

@@ 21-55 (lines=35) @@
18
use FeedIo\RuleAbstract;
19
use FeedIo\FeedInterface;
20
21
class Logo extends RuleAbstract
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
    public function setProperty(NodeInterface $node, \DOMElement $element) : void
31
    {
32
        if ($node instanceof FeedInterface) {
33
            $node->setLogo($element->nodeValue);
34
        }
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    protected function hasValue(NodeInterface $node) : bool
41
    {
42
        return $node instanceof FeedInterface && !! $node->getLogo();
43
    }
44
45
    /**
46
     * @inheritDoc
47
     */
48
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node) : void
49
    {
50
        if (!($node instanceof FeedInterface) || is_null($node->getLogo())) {
51
            return;
52
        }
53
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getLogo()));
54
    }
55
}
56

src/FeedIo/Rule/Language.php 1 location

@@ 17-53 (lines=37) @@
14
use FeedIo\FeedInterface;
15
use FeedIo\RuleAbstract;
16
17
class Language extends RuleAbstract
18
{
19
    const NODE_NAME = 'language';
20
21
    /**
22
     * @param  NodeInterface $node
23
     * @param  \DOMElement   $element
24
     */
25
    public function setProperty(NodeInterface $node, \DOMElement $element): void
26
    {
27
        if ($node instanceof FeedInterface) {
28
            $node->set(static::NODE_NAME, $element->nodeValue);
29
        }
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    protected function hasValue(NodeInterface $node) : bool
36
    {
37
        return $node instanceof FeedInterface && !! $node->getLanguage();
38
    }
39
40
    /**
41
     * creates the accurate DomElement content according to the $item's property
42
     *
43
     * @param  \DomDocument  $document
44
     * @param  NodeInterface $node
45
     */
46
    public function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node): void
47
    {
48
        if (!($node instanceof FeedInterface) || is_null($node->getLanguage())) {
49
            return;
50
        }
51
        $rootElement->appendChild($document->createElement($this->getNodeName(), $node->getLanguage()));
52
    }
53
}
54