Completed
Pull Request — master (#150)
by Brent
02:40
created

CrawlRequestFailed::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Spatie\Crawler\Handlers;
4
5
use Spatie\Crawler\Crawler;
6
use GuzzleHttp\Exception\RequestException;
7
8
class CrawlRequestFailed
9
{
10
    /** @var \Spatie\Crawler\Crawler */
11
    private $crawler;
12
13
    public function __construct(Crawler $crawler)
14
    {
15
        $this->crawler = $crawler;
16
    }
17
18
    public function __invoke(RequestException $exception, $index)
19
    {
20
        $crawlUrl = $this->crawler->getCrawlQueue()->getUrlById($index);
21
22
        $this->crawler->getCrawlObservers()->crawlFailed($crawlUrl, $exception);
23
    }
24
}
25