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

CrawlerRestart::getHarvester()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
eloc 9
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 15
rs 9.9666
ccs 7
cts 7
cp 1
crap 4
1
<?php
2
3
namespace PiedWeb\SeoPocketCrawler;
4
5
class CrawlerRestart extends CrawlerContinue
6
{
7
    public function __construct(
8
        string $id,
9
        bool $fromCache = false,
10 3
        bool $debug = true,
11
        ?string $dataDirectory = null
12 3
    ) {
13
        if (true === $fromCache) {
14 3
            $this->harvester = '\PiedWeb\SeoPocketCrawler\CrawlerUrlFromCache';
15
        }
16 3
17 3
        $this->config = CrawlerConfig::loadFrom($id, $dataDirectory);
18
19 3
        $this->resetLinks();
20
21 3
        //$this->recorder = new Recorder($this->config->getDataFolder(), $this->config->getCacheMethod());
22 3
23 3
        $this->urls[$this->config->getStartUrl()] = null;
24
25 3
        $this->debug = $debug;
26
    }
27 3
28 3
    protected function resetLinks()
29
    {
30 3
        exec('rm -rf '.$this->config->getDataFolder().Recorder::LINKS_DIR);
31
    }
32
}
33