GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Observer::crawlFailed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Spatie\Export\Crawler;
4
5
use GuzzleHttp\Exception\RequestException;
6
use Psr\Http\Message\ResponseInterface;
7
use Psr\Http\Message\UriInterface;
8
use RuntimeException;
9
use Spatie\Crawler\CrawlObserver;
10
use Spatie\Export\Destination;
11
use Spatie\Export\Traits\NormalizedPath;
12
13
class Observer extends CrawlObserver
14
{
15
    use NormalizedPath;
16
17
    /** @var string */
18
    protected $entry;
19
20
    /** @var \Spatie\Export\Destination */
21
    protected $destination;
22
23
    public function __construct(string $entry, Destination $destination)
24
    {
25
        $this->entry = $entry;
26
        $this->destination = $destination;
27
    }
28
29
    public function crawled(UriInterface $url, ResponseInterface $response, ?UriInterface $foundOnUrl = null)
30
    {
31
        if ($response->getStatusCode() !== 200) {
32
            throw new RuntimeException("URL [{$url}] returned status code [{$response->getStatusCode()}]");
33
        }
34
      
35
        $this->destination->write(
36
            $this->normalizePath($url->getPath()),
37
            (string) $response->getBody()
38
        );
39
    }
40
41
    public function crawlFailed(UriInterface $url, RequestException $requestException, ?UriInterface $foundOnUrl = null)
42
    {
43
        throw $requestException;
44
    }
45
}
46