Passed
Push — master ( 6700a9...62f4d8 )
by Dev
12:41
created

CrawlerUrlFromCache   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 1
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHarvester() 0 24 5
1
<?php
2
3
namespace PiedWeb\SeoPocketCrawler;
4
5
use PiedWeb\Curl\ResponseFromCache;
6
use PiedWeb\UrlHarvester\Harvest;
7
8
class CrawlerUrlFromCache extends CrawlerUrl
9
{
10
    public function getHarvester()
11
    {
12
        if (null !== $this->harvest) {
13
            return $this->harvest;
14
        }
15
16
        $filePath = $this->config->getRecorder()->getCacheFilePath($this->url);
17
        if (null !== $filePath && file_exists($filePath)) {
18
            $response = new ResponseFromCache(
19
                $filePath,
20
                $this->config->getBase().$this->url->getUri(),
21
                json_decode(file_get_contents($filePath.'---info'), true)
22
            );
23
24
            $this->harvest = new Harvest($response);
25
        }
26
27
        $this->harvest ?? $this->harvest = parent::getHarvester();
28
29
        if (null !== $this->config->getRobotsTxtCached()) {
30
            $this->harvest->setRobotsTxt($this->config->getRobotsTxtCached());
0 ignored issues
show
Bug introduced by
The method setRobotsTxt() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
            $this->harvest->/** @scrutinizer ignore-call */ 
31
                            setRobotsTxt($this->config->getRobotsTxtCached());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
        }
32
33
        return $this->harvest;
34
    }
35
}
36