ClassMapBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 20
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 13 3
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\DependencyInjection\Container;
12
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
15
/**
16
 * ClassMapBuilder builds a ClassMap from ContainerBuilder.
17
 * Since it makes no sense to have private services in ClassMap, ClassMapBuilder should be run
18
 * by a CompilerPass with type TYPE_REMOVE (after removing private services).
19
 *
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class ClassMapBuilder
23
{
24
    /**
25
     * @param ContainerBuilder $container
26
     *
27
     * @return array
28
     */
29 19
    public function build(ContainerBuilder $container)
30
    {
31 19
        $map = [];
32
33 19
        foreach ($container->getDefinitions() as $id => $definition) {
34 19
            $map[$id] = $definition->getClass();
35
        }
36
37 19
        foreach ($container->getAliases() as $id => $alias) {
38 1
            $map[$id] = $map[(string) $alias];
39
        }
40
41 19
        return $map;
42
    }
43
}
44