| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 85.71% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class ClassResolverCache |
||
| 18 | { |
||
| 19 | use EventDispatchingCapabilities; |
||
| 20 | |||
| 21 | private static ?CacheInterface $cache = null; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @internal |
||
| 25 | */ |
||
| 26 | 22 | public static function resetCache(): void |
|
| 27 | { |
||
| 28 | 22 | self::$cache = null; |
|
| 29 | } |
||
| 30 | |||
| 31 | 18 | public static function getCache(): CacheInterface |
|
| 32 | { |
||
| 33 | 18 | if (self::$cache !== null) { |
|
| 34 | self::dispatchEvent(new ClassNameCacheCachedEvent()); |
||
| 35 | return self::$cache; |
||
| 36 | } |
||
| 37 | |||
| 38 | 18 | if (self::isEnabled()) { |
|
| 39 | 3 | self::dispatchEvent(new ClassNamePhpCacheCreatedEvent()); |
|
| 40 | |||
| 41 | 3 | self::$cache = new ClassNamePhpCache(Config::getInstance()->getCacheDir()); |
|
| 42 | } else { |
||
| 43 | 15 | self::dispatchEvent(new ClassNameInMemoryCacheCreatedEvent()); |
|
| 44 | 15 | self::$cache = new InMemoryCache(ClassNamePhpCache::class); |
|
| 45 | } |
||
| 46 | |||
| 47 | 18 | return self::$cache; |
|
|
|
|||
| 48 | } |
||
| 49 | |||
| 50 | 18 | private static function isEnabled(): bool |
|
| 53 | } |
||
| 54 | } |
||
| 55 |