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

GacelaCache   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A isProjectCacheEnabled() 0 7 2
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