Completed
Push — master ( a0e8ce...60fa13 )
by Bas
12s
created

FilesystemManagerFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace BsbFlysystem\Service\Factory;
4
5
use BsbFlysystem\Filesystem\Factory\FilesystemFactory;
6
use BsbFlysystem\Service\FilesystemManager;
7
use Interop\Container\ContainerInterface;
8
use Zend\ServiceManager\FactoryInterface;
9
use Zend\ServiceManager\ServiceLocatorInterface;
10
11
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...
12
{
13
    /**
14
     * Create service
15
     *
16
     * @param ServiceLocatorInterface $serviceLocator
17
     *
18
     * @return mixed
19
     */
20
    public function createService(ServiceLocatorInterface $serviceLocator)
21
    {
22
        return $this($serviceLocator, null);
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 1
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
29
    {
30 1
        $config        = $container->get('config');
31 1
        $config        = $config['bsb_flysystem']['filesystems'];
32 1
        $serviceConfig = [];
33 1
        foreach ($config as $key => $filesystems) {
34 1
            $serviceConfig['factories'][$key] = FilesystemFactory::class;
35 1
            $serviceConfig['shared'][$key]    = isset($filesystems['shared']) ? (bool) $filesystems['shared'] : true;
36
        }
37
38 1
        return new FilesystemManager($container, $serviceConfig);
39
    }
40
}
41