Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| CacheInitializationTrait | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| initializeCache | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace BO\Slim\Traits; |
| 6 | |
| 7 | use BO\Slim\Helper\CacheBootstrap; |
| 8 | |
| 9 | /** |
| 10 | * Shared cache initialization for module Application classes. |
| 11 | * |
| 12 | * Expects the using class to declare: |
| 13 | * - public static ?\Psr\SimpleCache\CacheInterface $cache |
| 14 | * - public static string $CACHE_DIR |
| 15 | * - public static int $SOURCE_CACHE_TTL |
| 16 | */ |
| 17 | trait CacheInitializationTrait |
| 18 | { |
| 19 | private static function initializeCache(?string $fallbackCacheDir = null): void |
| 20 | { |
| 21 | [$cacheDir, $ttl] = CacheBootstrap::resolveConfig($fallbackCacheDir); |
| 22 | static::$CACHE_DIR = $cacheDir; |
| 23 | static::$SOURCE_CACHE_TTL = $ttl; |
| 24 | static::$cache = CacheBootstrap::create($cacheDir, $ttl); |
| 25 | } |
| 26 | } |