Spatie\LinkChecker\Reporters\BaseReporter::hasBeenCrawled PHP Method

hasBeenCrawled() public method

Called when the crawler has crawled the given url.
public hasBeenCrawled ( Url $url, Psr\Http\Message\ResponseInterface | null $response ) : string
$url Spatie\Crawler\Url
$response Psr\Http\Message\ResponseInterface | null
return string
    public function hasBeenCrawled(Url $url, $response)
    {
        $statusCode = $response ? $response->getStatusCode() : static::UNRESPONSIVE_HOST;
        $this->urlsGroupedByStatusCode[$statusCode][] = $url;
        return $statusCode;
    }

Same methods

BaseReporter::hasBeenCrawled ( Url $url, Psr\Http\Message\ResponseInterface | null $response, Url $foundOnUrl = null ) : string

Usage Example

 /**
  * Called when the crawler has crawled the given url.
  *
  * @param \Spatie\Crawler\Url                      $url
  * @param \Psr\Http\Message\ResponseInterface|null $response
  *
  * @return string
  */
 public function hasBeenCrawled(Url $url, $response)
 {
     $statusCode = parent::hasBeenCrawled($url, $response);
     if ($this->isSuccessOrRedirect($statusCode)) {
         return;
     }
     $reason = $response ? $response->getReasonPhrase() : '';
     $this->log->warning("{$statusCode} {$reason} - {$url}");
 }
All Usage Examples Of Spatie\LinkChecker\Reporters\BaseReporter::hasBeenCrawled