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
Pull Request — master (#115)
by
unknown
01:21
created

WatcherFactory::getDefaultOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spatie\PhpUnitWatcher;
4
5
use InvalidArgumentException;
6
use Symfony\Component\Finder\Finder;
7
8
class WatcherFactory
9
{
10
    public static function create(array $options = []): array
11
    {
12
        $options = static::mergeWithDefaultOptions($options);
13
14
        if (empty($options['watch']['directories'])) {
15
            throw new InvalidArgumentException(
16
                'The watch directories do not exist. Make sure you are running the watcher from '.
17
                'the root of your project, or create a custom config file.'
18
            );
19
        }
20
21
        $finder = (new Finder())
22
            ->ignoreDotFiles(false)
23
            ->ignoreVCS(false)
24
            ->name($options['watch']['fileMask'])
25
            ->files()
26
            ->in($options['watch']['directories']);
27
28
        $watcher = new Watcher($finder, $options);
29
30
        return [$watcher, $options];
31
    }
32
33
    public static function getDefaultOptions(): array
34
    {
35
        return [
36
            'watch' => [
37
                'directories' => [
38
                    'app',
39
                    'src',
40
                    'tests',
41
                ],
42
                'fileMask' => '*.php',
43
            ],
44
            'notifications' => [
45
                'passingTests' => true,
46
                'failingTests' => true,
47
            ],
48
            'hideManual' => false,
49
        ];
50
    }
51
52
    protected static function mergeWithDefaultOptions(array $options): array
53
    {
54
        $options = array_replace_recursive(self::getDefaultOptions(), $options);
55
56
        $options['watch']['directories'] = array_map(function ($directory) {
57
            return getcwd()."/{$directory}";
58
        }, $options['watch']['directories']);
59
60
        $options['watch']['directories'] = array_filter($options['watch']['directories'], function ($directory) {
61
            return file_exists($directory);
62
        });
63
64
        return $options;
65
    }
66
}
67