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 ( f579cb...82d2f6 )
by Freek
01:57
created

WatcherCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 5
dl 0
loc 53
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 10 1
A determineOptions() 0 8 1
A getOptionsFromConfigFile() 0 10 2
A displayOptions() 0 12 1
1
<?php
2
3
namespace Spatie\PhpUnitWatcher;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Console\Style\SymfonyStyle;
10
use Symfony\Component\Yaml\Yaml;
11
12
class WatcherCommand extends Command
13
{
14
    protected function configure()
15
    {
16
        $this->setName('watch')
17
            ->setDescription('Rerun PHPUnit tests when source code changes.')
18
            ->addArgument('phpunit-options', InputArgument::OPTIONAL, 'Options passed to phpunit');
19
    }
20
21
    protected function execute(InputInterface $input, OutputInterface $output)
22
    {
23
        $options = $this->determineOptions($input);
24
25
        list($watcher, $options) = WatcherFactory::create($options);
26
27
        $this->displayOptions($options, $input, $output);
28
29
        $watcher->startWatching();
30
    }
31
32
    protected function determineOptions(InputInterface $input): array
33
    {
34
        $options = $this->getOptionsFromConfigFile();
35
36
        $options['phpunitArguments'] = trim($input->getArgument('phpunit-options'), "'");
37
38
        return $options;
39
    }
40
41
    protected function getOptionsFromConfigFile(): array
42
    {
43
        $configFile = getcwd() . '/.phpunit-watcher.yml';
44
45
        if (! file_exists($configFile)) {
46
            return [];
47
        }
48
49
        return Yaml::parse(file_get_contents($configFile));
50
    }
51
52
    protected function displayOptions(array $options, InputInterface $input, OutputInterface $output)
53
    {
54
        $output = new SymfonyStyle($input, $output);
55
56
        $output->title("Starting PHPUnit Watcher");
57
58
        $output->text("Tests will be rerun when {$options['watch']['fileMask']} files are modified in");
59
60
        $output->listing($options['watch']['directories']);
61
62
        $output->newLine();
63
    }
64
}
65