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