Rdf::getMainElement()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the feed-io package.
4
 *
5
 * (c) Alexandre Debril <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace FeedIo\Standard;
12
13
use DOMDocument;
14
use FeedIo\Reader\Document;
15
use FeedIo\RuleSet;
16
use FeedIo\Rule\Structure;
17
18
class Rdf extends Rss
19
{
20
21
    /**
22
     * Format version
23
     */
24
    const VERSION = '1.0';
25
26
    /**
27
     * RDF document must have a <rdf> root node
28
     */
29
    const ROOT_NODE_TAGNAME = 'rdf';
30
31
    /**
32
     * publication date
33
     */
34
    const DATE_NODE_TAGNAME = 'dc:date';
35
36
    /**
37
     * Tells if the parser can handle the feed or not
38
     * @param  Document $document
39
     * @return boolean
40
     */
41 2 View Code Duplication
    public function canHandle(Document $document) : bool
0 ignored issues
show
Duplication introduced by
This method 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...
42
    {
43 2
        if (!isset($document->getDOMDocument()->documentElement->tagName)) {
44
            return false;
45
        }
46 2
        return false !== strpos($document->getDOMDocument()->documentElement->tagName, static::ROOT_NODE_TAGNAME);
47
    }
48
49
    /**
50
     * @param  DOMDocument $document
51
     * @return \DomElement
52
     */
53 2
    public function getMainElement(\DOMDocument $document) : \DOMElement
54
    {
55 2
        return $document->documentElement;
56
    }
57
58
    /**
59
     * @return RuleSet
60
     */
61 2
    public function buildFeedRuleSet() : RuleSet
62
    {
63 2
        $ruleSet = new RuleSet();
64 2
        $ruleSet->add(new Structure(static::CHANNEL_NODE_TAGNAME, $this->buildItemRuleSet()));
65
66 2
        return $ruleSet;
67
    }
68
}
69