Lines 100.00% 7 / 7
Methods 100.00% 1 / 1
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 resolve 100.00% 7 / 7 100.00% 1 / 1 5
29final class TwigCacheResolver
30{
31    /**
32     * @return string|false the cache directory, or false when caching is disabled
33     */
34    public static function resolve(
35        bool $debug,
36        mixed $enabled,
37        ?string $configuredDir,
38        string $defaultDir,
39    ): string|false {
40        if ($debug) {
41            return false;
42        }
43
44        if (!filter_var($enabled ?? 'true', FILTER_VALIDATE_BOOLEAN)) {
45            return false;
46        }
47
48        if ($configuredDir !== null && trim($configuredDir) !== '') {
49            return $configuredDir;
50        }
51
52        return $defaultDir;
53    }
54}