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

FlysystemCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 10
cc 3
nc 3
nop 1
crap 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