Passed
Pull Request — master (#593)
by butschster
10:42 queued 04:59
created

TokenizerConfig::getScope()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license MIT
7
 * @author  Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Tokenizer\Config;
13
14
use Spiral\Core\InjectableConfig;
15
16
/**
17
 * Tokenizer component configuration.
18
 */
19
final class TokenizerConfig extends InjectableConfig
20
{
21
    public const CONFIG = 'tokenizer';
22
23
    /** @var array<non-empty-string, array<int, non-empty-string>> */
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<non-empty-string, ...int, non-empty-string>> at position 2 could not be parsed: Unknown type name 'non-empty-string' at position 2 in array<non-empty-string, array<int, non-empty-string>>.
Loading history...
24
    protected $config = [
25
        'directories' => [],
26
        'exclude' => [],
27
        'scopes' => [],
28
    ];
29
30
    public function getDirectories(): array
31
    {
32
        return $this->config['directories'] ?? [getcwd()];
33
    }
34
35
    public function getExcludes(): array
36
    {
37
        return $this->config['exclude'] ?? ['vendor', 'tests'];
38
    }
39
40
    /**
41
     * @return array{directories: array<string>, exclude: array<string>}
42
     */
43
    public function getScope(string $scope): array
44
    {
45
        $directories = $this->config['scopes'][$scope]['directories'] ?? $this->getDirectories();
46
        $excludes = $this->config['scopes'][$scope]['exclude'] ?? $this->getExcludes();
47
48
        return [
49
            'directories' => $directories,
50
            'exclude' => $excludes,
51
        ];
52
    }
53
}
54