IlluminateAdapterFactory::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 2
rs 10
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