1 | <?php |
||
11 | abstract class BaseReporter extends CrawlObserver |
||
12 | { |
||
13 | const UNRESPONSIVE_HOST = 'Host did not respond'; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $urlsGroupedByStatusCode = []; |
||
19 | |||
20 | /** |
||
21 | * Called when the crawler has crawled the given url successfully. |
||
22 | * |
||
23 | * @param \Psr\Http\Message\UriInterface $url |
||
24 | * @param \Psr\Http\Message\ResponseInterface $response |
||
25 | * @param null|\Psr\Http\Message\UriInterface $foundOnUrl |
||
26 | * |
||
27 | * @return int|string |
||
28 | */ |
||
29 | public function crawled( |
||
42 | |||
43 | /** |
||
44 | * Called when the crawler had a problem crawling the given url. |
||
45 | * |
||
46 | * @param \Psr\Http\Message\UriInterface $url |
||
47 | * @param \GuzzleHttp\Exception\RequestException $requestException |
||
48 | * @param \Psr\Http\Message\UriInterface|null $foundOnUrl |
||
49 | */ |
||
50 | public function crawlFailed( |
||
63 | |||
64 | /** |
||
65 | * Determine if the statuscode concerns a successful or |
||
66 | * redirect response. |
||
67 | * |
||
68 | * @param int|string $statusCode |
||
69 | * @return bool |
||
70 | */ |
||
71 | protected function isSuccessOrRedirect($statusCode): bool |
||
75 | |||
76 | /** |
||
77 | * Determine if the crawler saw some bad urls. |
||
78 | */ |
||
79 | protected function crawledBadUrls(): bool |
||
85 | |||
86 | /** |
||
87 | * Determine if the statuscode should be excluded' |
||
88 | * from the reporter. |
||
89 | * |
||
90 | * @param int|string $statusCode |
||
91 | * |
||
92 | * @return bool |
||
93 | */ |
||
94 | protected function isExcludedStatusCode($statusCode): bool |
||
100 | } |
||
101 |