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

HttpLastModified   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A correct() 0 12 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