Passed
Push — feature/change-cache-to-profil... ( 160b60 )
by Chema
04:07
created

GacelaProfiler::isEnabled()   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 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
ccs 4
cts 4
cp 1
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Framework\ClassResolver\Profiler;
6
7
use Gacela\Framework\Config\ConfigInterface;
8
9
final class GacelaProfiler
10
{
11
    public const KEY_ENABLED = 'gacela-profiler-enabled';
12
    public const DEFAULT_DIRECTORY_VALUE = '.gacela/profiler';
13
14
    private ConfigInterface $config;
15
16 38
    public function __construct(ConfigInterface $config)
17
    {
18 38
        $this->config = $config;
19
    }
20
21 38
    public function isEnabled(): bool
22
    {
23 38
        if ($this->config->hasKey(self::KEY_ENABLED)) {
24 8
            return (bool)$this->config->get(self::KEY_ENABLED);
25
        }
26
27 30
        return $this->config->getSetupGacela()->isProfilerEnabled();
28
    }
29
}
30