FileSystemAdapterFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

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