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 ( 6a638f...c871b7 )
by Freek
02:02
created

ScanCommand::execute()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 28
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 17
nc 3
nop 2
1
<?php
2
3
namespace Spatie\HttpStatusCheck;
4
5
use Spatie\Crawler\Crawler;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Console\Question\ConfirmationQuestion;
12
13
class ScanCommand extends Command
14
{
15
    protected function configure()
16
    {
17
        $this->setName('scan')
18
            ->setDescription('Check the http status code of all links on a website.')
19
            ->addArgument(
20
                'url',
21
                InputArgument::REQUIRED,
22
                'The url to check'
23
            )
24
            ->addOption(
25
                'concurrency',
26
                'c',
27
                InputOption::VALUE_REQUIRED,
28
                'The amount of concurrent connections to use',
29
                10
30
            )
31
            ->addOption(
32
                'output',
33
                'o',
34
                InputOption::VALUE_REQUIRED,
35
                'The file to write the scan log for non 2xx responses'
36
            );
37
    }
38
39
    /**
40
     * @param \Symfony\Component\Console\Input\InputInterface $input
41
     * @param \Symfony\Component\Console\Output\OutputInterface $output
42
     *
43
     * @return int
44
     */
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        $baseUrl = $input->getArgument('url');
48
49
        $output->writeln("Start scanning {$baseUrl}");
50
        $output->writeln('');
51
52
        $crawlLogger = new CrawlLogger($output);
53
54
        if ($input->getOption('output')) {
55
            $outputFile = $input->getOption('output');
56
57
            if (file_exists($outputFile)) {
58
                $helper = $this->getHelper('question');
59
                $question = new ConfirmationQuestion('Overwrite existing file? ', false);
60
                $crawlLogger->setOverwriteOutputFile($helper->ask($input, $output, $question));
61
            }
62
63
            $crawlLogger->setOutputFile($input->getOption('output'));
64
        }
65
66
        Crawler::create()
67
            ->setConcurrency($input->getOption('concurrency'))
68
            ->setCrawlObserver($crawlLogger)
69
            ->startCrawling($baseUrl);
70
71
        return 0;
72
    }
73
}
74