IlluminateAdapterFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11PhpCache\Adapter;
6
7
use Cache\Adapter\Illuminate\IlluminateCachePool;
8
use Illuminate\Contracts\Cache\Store;
9
use Psr\Container\ContainerInterface;
10
use WShafer\PSR11PhpCache\Exception\InvalidConfigException;
11
12
class IlluminateAdapterFactory implements FactoryInterface
13
{
14 2
    public function __invoke(ContainerInterface $container, array $options): IlluminateCachePool
15
    {
16 2
        $cacheStoreName = (string)($options['store'] ?? '');
17
18 2
        $cacheStore = $container->get($cacheStoreName);
19
20 2
        if (!$cacheStore instanceof Store) {
21 1
            throw new InvalidConfigException(
22 1
                'Service provided for the Illuminate Cache must be an instance of ' . Store::class
23
            );
24
        }
25
26 1
        return new IlluminateCachePool($cacheStore);
27
    }
28
}
29