| Total Complexity | 7 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | final class GacelaFileCache |
||
| 11 | { |
||
| 12 | public const KEY_ENABLED = 'gacela-cache-enabled'; |
||
| 13 | |||
| 14 | public const DEFAULT_ENABLED_VALUE = false; |
||
| 15 | |||
| 16 | public const DEFAULT_DIRECTORY_VALUE = null; |
||
| 17 | 57 | ||
| 18 | private static ?bool $isEnabled = null; |
||
| 19 | |||
| 20 | 57 | public function __construct( |
|
| 21 | private readonly ConfigInterface $config, |
||
| 22 | ) { |
||
| 23 | } |
||
| 24 | |||
| 25 | 58 | /** |
|
| 26 | * @internal |
||
| 27 | 58 | */ |
|
| 28 | public static function resetCache(): void |
||
| 29 | { |
||
| 30 | 57 | self::$isEnabled = null; |
|
| 31 | } |
||
| 32 | 57 | ||
| 33 | 53 | public function isEnabled(): bool |
|
| 34 | 6 | { |
|
| 35 | 47 | if (self::$isEnabled === null) { |
|
| 36 | self::$isEnabled = $this->config->hasKey(self::KEY_ENABLED) |
||
| 37 | ? (bool)$this->config->get(self::KEY_ENABLED) |
||
| 38 | 57 | : $this->config->getSetupGacela()->isFileCacheEnabled(); |
|
| 39 | } |
||
| 40 | |||
| 41 | return self::$isEnabled; |
||
|
|
|||
| 42 | } |
||
| 43 | |||
| 44 | public static function isEnabledFromCacheConfig(CacheConfigurationInterface $cacheConfig): bool |
||
| 51 | } |
||
| 52 | } |
||
| 53 |