Passed
Pull Request — master (#968)
by Maxim
09:36
created

AttributesConfig::isCacheEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Bootloader\Attributes;
6
7
use Spiral\Core\InjectableConfig;
8
9
final class AttributesConfig extends InjectableConfig
10
{
11
    public const CONFIG = 'attributes';
12
13
    /**
14
     * @var array{
0 ignored issues
show
Documentation Bug introduced by
The doc comment array{ at position 2 could not be parsed: the token is null at position 2.
Loading history...
15
     *     annotations: array{support:bool},
16
     *     cache: array{storage: null|non-empty-string, enabled: bool},
17
     * }
18
     */
19
    protected array $config = [
20
        'annotations' => [
21
            'support' => true,
22
        ],
23
        'cache' => [
24
            'storage' => null,
25
            'enabled' => false,
26
        ],
27
    ];
28
29 377
    public function isAnnotationsReaderEnabled(): bool
30
    {
31 377
        return (bool)$this->config['annotations']['support'];
32
    }
33
34 377
    public function isCacheEnabled(): bool
35
    {
36 377
        return (bool)($this->config['cache']['enabled'] ?? false);
37
    }
38
39
    /**
40
     * @return non-empty-string|null
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string|null at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string|null.
Loading history...
41
     */
42 2
    public function getCacheStorage(): ?string
43
    {
44 2
        return $this->config['cache']['storage'] ?? null;
45
    }
46
}
47