Completed
Push — master ( 1909f4...1cc48d )
by Alex
18s queued 11s
created

LastModifiedSince::correct()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 4
nc 2
nop 1
crap 4
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\FeedInterface;
14
use FeedIo\Reader\FixerAbstract;
15
use FeedIo\Reader\Result;
16
17
class LastModifiedSince extends FixerAbstract
18
{
19
20
    /**
21
     * @param Result $result
22
     * @return FixerAbstract
23
     * @throws \Exception
24
     *
25
     */
26 3 View Code Duplication
    public function correct(Result $result) : FixerAbstract
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28 3
        $feed = $result->getFeed();
29 3
        $date = new \DateTime('@0');
30
31 3
        if (count($feed) === 0 && (is_null($feed->getLastModified()) || $feed->getLastModified() == $date)) {
32 1
            $this->logger->notice("set last modified date to modifiedSince arg for feed {$feed->getTitle()}");
33 1
            $feed->setLastModified($result->getModifiedSince());
34
        }
35
36 3
        return $this;
37
    }
38
}
39