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

TurnOnAutowireCompilerPass::hasConstructorArguments()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 9
ccs 4
cts 5
cp 0.8
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2.032
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