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

TurnOnAutowireCompilerPass::haveMissingArgumentsTypehints()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.2

Importance

Changes 2
Bugs 2 Features 0
Metric Value
c 2
b 2
f 0
dl 0
loc 19
ccs 8
cts 10
cp 0.8
rs 8.8571
cc 5
eloc 13
nc 4
nop 2
crap 5.2
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