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 ( cdf584...500099 )
by Brent
12s
created

src/Reporters/MailBrokenLinks.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Spatie\LinkChecker\Reporters;
4
5
use GuzzleHttp\Exception\RequestException;
6
use Illuminate\Contracts\Mail\Mailer;
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\UriInterface;
9
10
class MailBrokenLinks extends BaseReporter
11
{
12
    /**
13
     * @var Mailer
14
     */
15
    protected $mail;
16
17
    /**
18
     * MailBrokenLinks constructor.
19
     *
20
     * @param \Illuminate\Contracts\Mail\Mailer $mail
21
     */
22
    public function __construct(Mailer $mail)
23
    {
24
        $this->mail = $mail;
25
    }
26
27
    /**
28
     * Called when the crawl has ended.
29
     */
30
    public function finishedCrawling()
31
    {
32
        if (!$this->crawledBadUrls()) {
33
            return;
34
        }
35
36
        $urlsGroupedByStatusCode = $this->urlsGroupedByStatusCode;
37
38
        $this->mail->send('laravel-link-checker::crawlReport', compact('urlsGroupedByStatusCode'), function ($message) {
39
            $message->from(config('laravel-link-checker.reporters.mail.from_address'));
40
            $message->to(config('laravel-link-checker.reporters.mail.to_address'));
41
            $message->subject(config('laravel-link-checker.reporters.mail.subject'));
42
        });
43
    }
44
45
    /**
46
     * Called when the crawler has crawled the given url successfully.
47
     *
48
     * @param \Psr\Http\Message\UriInterface      $url
49
     * @param \Psr\Http\Message\ResponseInterface $response
50
     * @param \Psr\Http\Message\UriInterface|null $foundOnUrl
51
     */
52
    public function crawled(
53
        UriInterface $url,
54
        ResponseInterface $response,
55
        ?UriInterface $foundOnUrl = null
56
    ) {
57
        $url->foundOnUrl = $foundOnUrl;
0 ignored issues
show
Accessing foundOnUrl on the interface Psr\Http\Message\UriInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
58
59
        return parent::crawled($url, $response, $foundOnUrl);
60
    }
61
62
    /**
63
     * Called when the crawler had a problem crawling the given url.
64
     *
65
     * @param \Psr\Http\Message\UriInterface         $url
66
     * @param \GuzzleHttp\Exception\RequestException $requestException
67
     * @param \Psr\Http\Message\UriInterface|null    $foundOnUrl
68
     */
69
    public function crawlFailed(
70
        UriInterface $url,
71
        RequestException $requestException,
72
        ?UriInterface $foundOnUrl = null
73
    ) {
74
        return;
75
    }
76
}
77