Completed
Pull Request — master (#63)
by Alex
10:55 queued 08:50
created

ModifiedSince::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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