FilesystemManagerFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 20
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createService() 0 4 1
A __invoke() 0 12 3
1
<?php
2
3
/**
4
 * BsbFlystem
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @see       https://bushbaby.nl/
10
 *
11
 * @copyright Copyright (c) 2014-2021 bushbaby multimedia. (https://bushbaby.nl)
12
 * @author    Bas Kamer <[email protected]>
13
 * @license   MIT
14
 *
15
 * @package   bushbaby/flysystem
16
 */
17
18
declare(strict_types=1);
19
20 1
namespace BsbFlysystem\Service\Factory;
21
22 1
use BsbFlysystem\Filesystem\Factory\FilesystemFactory;
23 1
use BsbFlysystem\Service\FilesystemManager;
24 1
use Psr\Container\ContainerInterface;
25 1
26 1
class FilesystemManagerFactory
27 1
{
28
    public function createService(ContainerInterface $container): FilesystemManager
29
    {
30 1
        return $this($container, null);
31
    }
32
33
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): FilesystemManager
34
    {
35
        $config = $container->get('config');
36
        $config = $config['bsb_flysystem']['filesystems'];
37
        $serviceConfig = [];
38
        foreach ($config as $key => $filesystems) {
39
            $serviceConfig['factories'][$key] = FilesystemFactory::class;
40
            $serviceConfig['shared'][$key] = isset($filesystems['shared']) ? (bool) $filesystems['shared'] : true;
41
        }
42
43
        return new FilesystemManager($container, $serviceConfig);
44
    }
45
}
46