| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 1 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 7 | public function __invoke(ContainerInterface $container): CacheInterface |
|
| 25 | { |
||
| 26 | $cache = $container->get('config')['soluble-mediatools']['cache'] ?? null; |
||
| 27 | if ($cache === null) { |
||
| 28 | return new NullCache(); |
||
| 29 | } elseif (!is_callable($cache)) { |
||
| 30 | throw new ConfigException("Config exception, 'cache' must be callable or null"); |
||
| 31 | } |
||
| 32 | |||
| 33 | $c = $cache(); |
||
| 34 | if (!$c instanceof CacheInterface) { |
||
| 35 | throw new ConfigException("Config exception, 'cache' must return a psr16 cache implementation"); |
||
| 36 | } |
||
| 37 | |||
| 38 | return $c; |
||
| 39 | } |
||
| 41 |