Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 68.42% |
Changes | 0 |
1 | <?php |
||
7 | final class DocsetGrabber |
||
8 | { |
||
9 | public $docset; |
||
10 | |||
11 | |||
12 | 24 | public function __construct(Docset $docset) |
|
13 | { |
||
14 | 24 | $this->docset = $docset; |
|
15 | 24 | } |
|
16 | |||
17 | 8 | public function sitemapExists() |
|
18 | { |
||
19 | 8 | return @file_get_contents("https://{$this->docset->url()}/sitemap.xml"); |
|
20 | } |
||
21 | |||
22 | public function grabFromSitemap() |
||
23 | { |
||
24 | system( |
||
25 | "echo; wget {$this->docset->url()}/sitemap.xml --quiet --output-document - | \ |
||
26 | egrep --only-matching '{$this->docset->url()}[^<]+' | \ |
||
27 | wget --input-file - {$this->wgetOptions()}", |
||
28 | $result |
||
29 | ); |
||
30 | |||
31 | return $result === 0; |
||
32 | } |
||
33 | |||
34 | 8 | public function grabFromIndex() |
|
35 | { |
||
36 | 8 | system( |
|
37 | 8 | "echo; wget {$this->docset->url()} {$this->wgetOptions()}", |
|
38 | $result |
||
39 | ); |
||
40 | |||
41 | 8 | return $result === 0; |
|
42 | } |
||
43 | |||
44 | 8 | protected function wgetOptions() |
|
54 | -e robots=off \ |
||
55 | --quiet \ |
||
56 | --show-progress"; |
||
57 | } |
||
58 | } |
||
59 |