Completed
Push — master ( 60fa13...455325 )
by Bas
15:24
created

FilesystemManagerFactory::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 3
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BsbFlysystem\Service\Factory;
6
7
use BsbFlysystem\Filesystem\Factory\FilesystemFactory;
8
use BsbFlysystem\Service\FilesystemManager;
9
use Interop\Container\ContainerInterface;
10
use Zend\ServiceManager\FactoryInterface;
11
use Zend\ServiceManager\ServiceLocatorInterface;
12
13
class FilesystemManagerFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
14
{
15 1
    public function createService(ServiceLocatorInterface $serviceLocator): FilesystemManager
16
    {
17 1
        return $this($serviceLocator, null);
18
    }
19
20 1
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): FilesystemManager
21
    {
22 1
        $config        = $container->get('config');
23 1
        $config        = $config['bsb_flysystem']['filesystems'];
24 1
        $serviceConfig = [];
25 1
        foreach ($config as $key => $filesystems) {
26 1
            $serviceConfig['factories'][$key] = FilesystemFactory::class;
27 1
            $serviceConfig['shared'][$key]    = isset($filesystems['shared']) ? (bool) $filesystems['shared'] : true;
28
        }
29
30 1
        return new FilesystemManager($container, $serviceConfig);
31
    }
32
}
33