1 | <?php |
||
21 | class LinkCheckProvider |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * |
||
26 | * @var HttpStream |
||
27 | */ |
||
28 | private $httpClient; |
||
29 | |||
30 | /** |
||
31 | * |
||
32 | * @var OutputStream |
||
33 | */ |
||
34 | private $output; |
||
35 | |||
36 | /** |
||
37 | * |
||
38 | * @var Url |
||
39 | */ |
||
40 | private $url; |
||
41 | |||
42 | /** |
||
43 | * Create a new instance of LinkCheckProvider |
||
44 | * |
||
45 | * @param Url $url |
||
46 | * The url to check |
||
47 | */ |
||
48 | 1 | public function __construct(Url $url) |
|
54 | |||
55 | /** |
||
56 | * Override the standard output stream using a custom output stream instance |
||
57 | * |
||
58 | * @param OutputStream $stream |
||
59 | */ |
||
60 | 1 | public function setOutput(OutputStream $stream) |
|
64 | |||
65 | /** |
||
66 | * Perform check |
||
67 | * - Retrieve the contents of url |
||
68 | * - Extract all anchor links |
||
69 | * - Check all anchor links for existance (response code < 400) |
||
70 | * |
||
71 | * @param array $options |
||
72 | * The options for check ('recursive' => perform a recursive check of all same-site-links) |
||
73 | */ |
||
74 | 1 | public function check(array $options = array()) |
|
95 | |||
96 | 1 | private function extractAndCheckUrls(string $response, array $options) |
|
122 | |||
123 | 1 | private function checkSameSiteUrl(Url $url, array $options) |
|
137 | } |