Completed
Pull Request — master (#317)
by Alex
15:16 queued 05:16
created

Image   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 8 2
A hasValue() 0 4 1
A addElement() 0 4 1
1
<?php declare(strict_types=1);
2
3
4
namespace FeedIo\Rule;
5
6
7
use FeedIo\Feed\ItemInterface;
8
use FeedIo\Feed\NodeInterface;
9
10
class Image extends \FeedIo\RuleAbstract
11
{
12
13
    const NODE_NAME = 'image';
14
15
    /**
16
     * @inheritDoc
17
     */
18
    public function setProperty(NodeInterface $node, \DOMElement $element): void
19
    {
20
        if ($node instanceof ItemInterface) {
21
            $media = new \FeedIo\Feed\Item\Media();
22
            $media->setUrl($element->textContent);
23
            $node->addMedia($media);
24
        }
25
    }
26
27
    /**
28
     * @inheritDoc
29
     */
30
    protected function hasValue(NodeInterface $node): bool
31
    {
32
        return false;
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    protected function addElement(\DomDocument $document, \DOMElement $rootElement, NodeInterface $node): void
39
    {
40
        throw new \RuntimeException("you should not try to write a <image> tag");
41
    }
42
}
43