Completed
Push — issue/134 ( d0dc5e...07c20b )
by Alex
01:47
created

ModifiedSince   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setProperty() 0 6 1
A createElement() 0 9 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 8
    public function setProperty(NodeInterface $node, \DOMElement $element)
26
    {
27 8
        $node->setLastModified($this->getDateTimeBuilder()->convertToDateTime($element->nodeValue));
28
29 8
        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 3
    public function createElement(\DomDocument $document, NodeInterface $node)
40
    {
41 3
        $date = is_null($node->getLastModified()) ? new \DateTime():$node->getLastModified();
42
43 3
        return $document->createElement(
44 3
            $this->getNodeName(),
45 3
            $date->format($this->getDefaultFormat())
46 3
        );
47
    }
48
}
49