Completed
Push — issue/60 ( b48df4 )
by Alex
04:17
created

ModifiedSince::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
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\Filter;
12
13
use FeedIo\FeedInterface;
14
use FeedIo\Feed\ItemInterface;
15
use FeedIo\FilterInterface;
16
17
class ModifiedSince implements FilterInterface
18
{
19
    /**
20
     * @var \DateTime
21
     */
22
    protected $date;
23
24
    /**
25
     * ModifiedSince constructor.
26
     * @param \DateTime $date
27
     */
28 3
    public function __construct(\DateTime $date)
29
    {
30 3
        $this->date = $date;
31 3
    }
32
33
34
    /**
35
     * @param  ItemInterface $item
36
     * @return bool
37
     */
38 3
    public function isValid(ItemInterface $item)
39
    {
40 3
        if ($item->getLastModified() instanceof \DateTime) {
41 2
            return $item->getLastModified() > $this->date;
42
        }
43
44 1
        return false;
45
    }
46
}
47