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.
Completed
Push — master ( 5482a6...347bee )
by Sebastian
17s queued 13s
created

Observer::normalizePath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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