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 ( aefbce...c9b60e )
by Freek
06:39
created

src/CheckLinksCommand.php (2 issues)

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;
4
5
use Exception;
6
use Illuminate\Console\Command;
7
use Spatie\Crawler\Crawler;
8
use Spatie\Crawler\CrawlObserver;
9
use Spatie\Crawler\CrawlProfile;
10
11
class CheckLinksCommand extends Command
12
{
13
    /**
14
     * The console command name.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'link-checker:run
19
                        {--url= : the url to be crawler}
20
                        {--profile= : The profiler to be used}
21
                        {--reporter= : The reporter to be used}
22
                        {--concurrency=10 : The amount of concurrent requests}
23
                        ';
24
    /**
25
     * The console command description.
26
     *
27
     * @var string
28
     */
29
    protected $description = 'Check all links';
30
31
    public function handle()
32
    {
33
        Crawler::create()
34
            ->setCrawlProfile($this->getProfile())
35
            ->setCrawlObserver($this->getReporter())
36
            ->startCrawling($this->getUrlToBeCrawled());
37
38
        $this->info('All done!');
39
    }
40
41
    /**
42
     * Determine the url to be crawled.
43
     *
44
     * @return null|string
45
     *
46
     * @throws \Exception
47
     */
48
    protected function getUrlToBeCrawled()
49
    {
50
        if (!is_null($this->option('url'))) {
51
            return $this->option('url');
52
        }
53
54
        if (config('laravel-link-checker.url') != '') {
55
            return config('laravel-link-checker.url');
56
        }
57
58
        if (config('app.url') != '') {
59
            return config('app.url');
60
        }
61
62
        throw new Exception('could not determine which url to be crawled.');
63
    }
64
65
    /**
66
     * Get the profile.
67
     */
68 View Code Duplication
    protected function getProfile(): CrawlProfile
69
    {
70
        if (!is_null($this->option('profile'))) {
71
            return app($this->option('profile'));
0 ignored issues
show
It seems like $this->option('profile') targeting Illuminate\Console\Command::option() can also be of type array; however, app() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
72
        }
73
74
        if (config('laravel-link-checker.default_profile') != '') {
75
            return app(config('laravel-link-checker.default_profile'));
76
        }
77
78
        throw new Exception('Could not determine the profile to be used');
79
    }
80
81
    /**
82
     * Get the reporter.
83
     */
84 View Code Duplication
    protected function getReporter(): CrawlObserver
85
    {
86
        if (!is_null($this->option('reporter'))) {
87
            return app($this->option('reporter'));
0 ignored issues
show
It seems like $this->option('reporter') targeting Illuminate\Console\Command::option() can also be of type array; however, app() does only seem to accept string|null, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
88
        }
89
90
        if (config('laravel-link-checker.default_reporter') != '') {
91
            return app(config('laravel-link-checker.default_reporter'));
92
        }
93
94
        throw new Exception('Could not reporter the profile to be used');
95
    }
96
}
97