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
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
    {
70
        if (!is_null($this->option('profile'))) {
71
            return app($this->option('profile'));
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
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
85
    {
86
        if (!is_null($this->option('reporter'))) {
87
            return app($this->option('reporter'));
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