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