Passed
Push — fix/set-cache-enabled-false-no... ( cd2779 )
by Jesús
09:26
created

GacelaCache::isProjectCacheEnabled()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\Cache;
6
7
use Gacela\Framework\Config\ConfigInterface;
8
9
final class GacelaCache
10
{
11
    public const KEY_ENABLED = 'gacela-cache-enabled';
12
    public const DEFAULT_ENABLED_VALUE = true;
13
    public const DEFAULT_DIRECTORY_VALUE = '.gacela/cache';
14
15
    private ConfigInterface $config;
16
17 32
    public function __construct(ConfigInterface $config)
18
    {
19 32
        $this->config = $config;
20
    }
21
22 32
    public function isProjectCacheEnabled(): bool
23
    {
24 32
        if (!$this->config->getSetupGacela()->isCacheEnabled()) {
25 1
            return false;
26
        }
27
28 31
        return (bool) $this->config->get(self::KEY_ENABLED, self::DEFAULT_ENABLED_VALUE);
29
    }
30
}
31