Completed
Push — issue/134 ( 534dd9 )
by Alex
02:01
created

Rdf   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 48
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandle() 0 4 1
A getMainElement() 0 4 1
A buildFeedRuleSet() 0 7 1
1
<?php
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
    public function canHandle(Document $document)
42
    {
43
        return false !== strpos($document->getDOMDocument()->documentElement->tagName, static::ROOT_NODE_TAGNAME);
44
    }
45
46
    /**
47
     * @param  DOMDocument $document
48
     * @return \DomElement
49
     */
50
    public function getMainElement(\DOMDocument $document)
51
    {
52
        return $document->documentElement;
53
    }
54
55
    /**
56
     * @return RuleSet
57
     */
58
    public function buildFeedRuleSet()
59
    {
60
        $ruleSet = new RuleSet();
61
        $ruleSet->add(new Structure(static::CHANNEL_NODE_TAGNAME, $this->buildItemRuleSet()));
62
63
        return $ruleSet;
64
    }
65
}
66