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

FilesystemManagerFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 30
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 3
A createService() 0 4 1
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