Passed
Pull Request — master (#52)
by Daniel
05:37
created

FlysystemCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 11 3
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Component Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentBundle\DependencyInjection\CompilerPass;
15
16
use Silverback\ApiComponentBundle\Flysystem\FilesystemProvider;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
/**
22
 * @author Daniel West <[email protected]>
23
 */
24
class FlysystemCompilerPass implements CompilerPassInterface
25
{
26 1
    public function process(ContainerBuilder $container): void
27
    {
28 1
        $definition = $container->getDefinition(FilesystemProvider::class);
29 1
        $taggedServices = $container->findTaggedServiceIds(FilesystemProvider::FILESYSTEM_ADAPTER_TAG);
30 1
        foreach ($taggedServices as $serviceId => $tags) {
31 1
            foreach ($tags as $attributes) {
32 1
                $definition->addMethodCall(
33 1
                    'addAdapter',
34
                    [
35 1
                        $attributes['alias'],
36 1
                        new Reference($serviceId),
37
                    ]
38
                );
39
            }
40
        }
41 1
    }
42
}
43