Conditions | 3 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
21 | 3 | public function __invoke(array $options) |
|
22 | { |
||
23 | 3 | if (empty($options['adaptor'])) { |
|
24 | 1 | throw new MissingConfigException( |
|
25 | 1 | 'Unable to locate cache file adaptor in config' |
|
26 | ); |
||
27 | } |
||
28 | |||
29 | 2 | $adaptor = $options['adaptor']; |
|
30 | 2 | $fileName = $options['fileName'] ?? 'file_cache'; |
|
31 | 2 | $ttl = $options['ttl'] ?? null; |
|
32 | |||
33 | /** @var FlySystemManager $manager */ |
||
34 | 2 | $manager = FlySystemFactory::getFlySystemManager($this->getContainer()); |
|
35 | 2 | $adaptorManager = $manager->getAdaptorManager(); |
|
36 | |||
37 | 2 | if (!$adaptorManager->has($adaptor)) { |
|
38 | 1 | throw new MissingServiceException( |
|
39 | 1 | 'Unable to locate file system: '.$adaptor |
|
40 | ); |
||
41 | } |
||
42 | |||
43 | 1 | return new Adapter($adaptorManager->get($adaptor), $fileName, $ttl); |
|
44 | } |
||
45 | } |
||
46 |