for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\Crawler\Handlers;
use Spatie\Crawler\Crawler;
use Spatie\Crawler\CrawlUrl;
use Spatie\Crawler\LinkAdder;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\ResponseInterface;
abstract class CrawlRequestFulfilledAbstract
{
/** @var \Spatie\Crawler\Crawler */
protected $crawler;
/** @var \Spatie\Crawler\LinkAdder */
protected $linkAdder;
public function __construct(Crawler $crawler)
$this->crawler = $crawler;
$this->linkAdder = new LinkAdder($this->crawler);
}
abstract public function __invoke(ResponseInterface $response, $index);
protected function handleCrawled(ResponseInterface $response, CrawlUrl $crawlUrl)
$this->crawler->getCrawlObservers()->crawled($crawlUrl, $response);
protected function convertBodyToString(StreamInterface $bodyStream, $readMaximumBytes = 1024 * 1024 * 2): string
$bodyStream->rewind();
$body = $bodyStream->read($readMaximumBytes);
return $body;