Completed
Pull Request — master (#42)
by Florent
12:58
created

FilesystemManagerFactory::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 12
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 Psr\Container\ContainerInterface;
10
11
class FilesystemManagerFactory
12
{
13
    public function createService(ContainerInterface $container): FilesystemManager
14
    {
15
        return $this($container, null);
16
    }
17
18
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null): FilesystemManager
19
    {
20
        $config = $container->get('config');
21
        $config = $config['bsb_flysystem']['filesystems'];
22
        $serviceConfig = [];
23
        foreach ($config as $key => $filesystems) {
24
            $serviceConfig['factories'][$key] = FilesystemFactory::class;
25
            $serviceConfig['shared'][$key] = isset($filesystems['shared']) ? (bool) $filesystems['shared'] : true;
26
        }
27
28
        return new FilesystemManager($container, $serviceConfig);
29
    }
30
}
31