| Conditions | 8 |
| Paths | 10 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | public function getHarvester(): ?Harvest |
||
| 11 | { |
||
| 12 | if (null !== $this->harvest) { |
||
| 13 | return $this->harvest === false ? null : $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 (!$this->harvest instanceof Harvest) { |
||
| 30 | $this->harvest = false; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (null !== $this->getHarvester() && null !== $this->config->getRobotsTxtCached()) { |
||
| 34 | $this->harvest->setRobotsTxt($this->config->getRobotsTxtCached()); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $this->getHarvester(); |
||
| 38 | } |
||
| 40 |