1 | <?php |
||
9 | class CrawlLogger implements CrawlObserver |
||
10 | { |
||
11 | const UNRESPONSIVE_HOST = 'Host did not respond'; |
||
12 | |||
13 | /** |
||
14 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
15 | */ |
||
16 | protected $consoleOutput; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $crawledUrls = []; |
||
22 | |||
23 | /** |
||
24 | * @var string|null |
||
25 | */ |
||
26 | protected $outputFile = null; |
||
27 | |||
28 | /** |
||
29 | * @param \Symfony\Component\Console\Output\OutputInterface $consoleOutput |
||
30 | */ |
||
31 | public function __construct(OutputInterface $consoleOutput) |
||
35 | |||
36 | /** |
||
37 | * Called when the crawl will crawl the url. |
||
38 | * |
||
39 | * @param \Spatie\Crawler\Url $url |
||
40 | */ |
||
41 | public function willCrawl(Url $url) |
||
44 | |||
45 | /** |
||
46 | * Called when the crawler has crawled the given url. |
||
47 | * |
||
48 | * @param \Spatie\Crawler\Url $url |
||
49 | * @param \Psr\Http\Message\ResponseInterface|null $response |
||
50 | * @param \Spatie\Crawler\Url $foundOn |
||
51 | */ |
||
52 | public function hasBeenCrawled(Url $url, $response, Url $foundOn = null) |
||
76 | |||
77 | /** |
||
78 | * Called when the crawl has ended. |
||
79 | */ |
||
80 | public function finishedCrawling() |
||
104 | |||
105 | protected function getColorTagForStatusCode(string $code): string |
||
117 | |||
118 | /** |
||
119 | * @param string|null $haystack |
||
120 | * @param string|array $needles |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | public function startsWith($haystack, $needles): bool |
||
134 | |||
135 | /** |
||
136 | * Set the filename to write the output log. |
||
137 | * |
||
138 | * @param string $filename |
||
139 | */ |
||
140 | public function setOutputFile($filename) |
||
144 | } |
||
145 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: