| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class DocBlockResolverCache |
||
| 18 | { |
||
| 19 | use EventDispatchingCapabilities; |
||
| 20 | |||
| 21 | private static ?CacheInterface $cache = null; |
||
| 22 | |||
| 23 | 22 | public static function resetCache(): void |
|
| 24 | { |
||
| 25 | 22 | self::$cache = null; |
|
| 26 | } |
||
| 27 | |||
| 28 | 25 | public static function getCacheInstance(): CacheInterface |
|
| 29 | { |
||
| 30 | 25 | if (self::$cache !== null) { |
|
| 31 | 15 | self::dispatchEvent(new CustomServicesCacheCachedEvent()); |
|
| 32 | |||
| 33 | 15 | return self::$cache; |
|
| 34 | } |
||
| 35 | |||
| 36 | 13 | if (self::isProjectCacheEnabled()) { |
|
| 37 | 4 | self::dispatchEvent(new CustomServicesPhpCacheCreatedEvent()); |
|
| 38 | 4 | self::$cache = new CustomServicesPhpCache(Config::getInstance()->getCacheDir()); |
|
| 39 | } else { |
||
| 40 | 9 | self::dispatchEvent(new CustomServicesInMemoryCacheCreatedEvent()); |
|
| 41 | 9 | self::$cache = new InMemoryCache(CustomServicesPhpCache::class); |
|
| 42 | } |
||
| 43 | |||
| 44 | 13 | return self::$cache; |
|
|
|
|||
| 45 | } |
||
| 46 | |||
| 47 | 13 | private static function isProjectCacheEnabled(): bool |
|
| 50 | } |
||
| 51 | } |
||
| 52 |