FilesystemManagerFactory::__invoke()   A
last analyzed

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 0
cp 0
rs 9.8666
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 12
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