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 ( 23cb2d...2cff12 )
by Brent
08:16
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 Illuminate\Contracts\Mail\Mailer;
6
use Psr\Http\Message\UriInterface;
7
8
class MailBrokenLinks extends BaseReporter
9
{
10
    /**
11
     * @var Mailer
12
     */
13
    protected $mail;
14
15
    /**
16
     * MailBrokenLinks constructor.
17
     *
18
     * @param \Illuminate\Contracts\Mail\Mailer $mail
19
     */
20
    public function __construct(Mailer $mail)
21
    {
22
        $this->mail = $mail;
23
    }
24
25
    /**
26
     * Called when the crawler has crawled the given url.
27
     *
28
     * @param \Psr\Http\Message\UriInterface           $url
29
     * @param \Psr\Http\Message\ResponseInterface|null $response
30
     * @param \Psr\Http\Message\UriInterface           $foundOnUrl
31
     *
32
     * @return string
33
     */
34
    public function hasBeenCrawled(UriInterface $url, $response, ?UriInterface $foundOnUrl = null)
35
    {
36
        $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...
37
38
        return parent::hasBeenCrawled($url, $response, $foundOnUrl);
39
    }
40
41
    /**
42
     * Called when the crawl has ended.
43
     */
44
    public function finishedCrawling()
45
    {
46
        if (!$this->crawledBadUrls()) {
47
            return;
48
        }
49
50
        $urlsGroupedByStatusCode = $this->urlsGroupedByStatusCode;
51
52
        $this->mail->send('laravel-link-checker::crawlReport', compact('urlsGroupedByStatusCode'), function ($message) {
53
            $message->from(config('laravel-link-checker.reporters.mail.from_address'));
54
            $message->to(config('laravel-link-checker.reporters.mail.to_address'));
55
            $message->subject(config('laravel-link-checker.reporters.mail.subject'));
56
        });
57
    }
58
}
59