Completed
Push — master ( 30142f...c651b6 )
by Alex
16s queued 11s
created

HttpLastModified::correct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php declare(strict_types=1);
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\Reader\Fixer;
12
13
use FeedIo\Reader\FixerAbstract;
14
use FeedIo\Reader\Result;
15
16
class HttpLastModified extends FixerAbstract
17
{
18
19
    /**
20
     * @param Result $result
21
     * @return FixerAbstract
22
     */
23 3
    public function correct(Result $result): FixerAbstract
24
    {
25 3
        $feed = $result->getFeed();
26 3
        $response = $result->getResponse();
27
28 3
        if ($feed->getLastModified() === null && $response->getLastModified() instanceof \DateTime) {
29 1
            $this->logger->debug("found last modified: " . $response->getLastModified()->format(\DateTime::RSS));
30 1
            $feed->setLastModified($response->getLastModified());
31
        }
32
33 3
        return $this;
34
    }
35
}
36