Completed
Push — master ( 3bca0f...4b95a7 )
by Tomáš
05:03 queued 02:28
created

TurnOnAutowireCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 3 Features 0
Metric Value
wmc 4
c 6
b 3
f 0
lcom 1
cbo 3
dl 0
loc 24
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 8 3
1
<?php
2
3
/*
4
 * This file is part of Symplify
5
 * Copyright (c) 2016 Tomas Votruba (http://tomasvotruba.cz).
6
 */
7
8
namespace Symplify\DefaultAutowire\DependencyInjection\Compiler;
9
10
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionAnalyzer;
13
14
final class TurnOnAutowireCompilerPass implements CompilerPassInterface
15
{
16
    /**
17
     * @var DefinitionAnalyzer
18
     */
19
    private $definitionAnalyzer;
20
21 2
    public function __construct(DefinitionAnalyzer $definitionAnalyzer)
22
    {
23 2
        $this->definitionAnalyzer = $definitionAnalyzer;
24 2
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 2
    public function process(ContainerBuilder $containerBuilder)
30
    {
31 2
        foreach ($containerBuilder->getDefinitions() as $definition) {
32 2
            if ($this->definitionAnalyzer->shouldDefinitionBeAutowired($definition)) {
33 2
                $definition->setAutowired(true);
34
            }
35
        }
36 2
    }
37
}
38