Completed
Push — issue/87 ( bbd942 )
by Alex
04:44
created

ModifiedSince::createElement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 2
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\Rule;
12
13
use FeedIo\Feed\NodeInterface;
14
use FeedIo\DateRuleAbstract;
15
16
class ModifiedSince extends DateRuleAbstract
17
{
18
    const NODE_NAME = 'pubDate';
19
20
    /**
21
     * @param  NodeInterface $node
22
     * @param  \DOMElement   $element
23
     * @return $this
24
     */
25 5
    public function setProperty(NodeInterface $node, \DOMElement $element)
26
    {
27 5
        $node->setLastModified($this->getDateTimeBuilder()->convertToDateTime($element->nodeValue));
28
29 5
        return $this;
30
    }
31
32
    /**
33
     * creates the accurate DomElement content according to the $item's property
34
     *
35
     * @param  \DomDocument  $document
36
     * @param  NodeInterface $node
37
     * @return \DomElement
38
     */
39
    public function createElement(\DomDocument $document, NodeInterface $node)
40
    {
41
        return $document->createElement(
42
            $this->getNodeName(),
43
            $node->getLastModified()->format($this->getDefaultFormat())
44
        );
45
    }
46
}
47