Completed
Pull Request — master (#6)
by Tomáš
03:49
created

TurnOnAutowireCompilerPass::shouldDefinitionBeAutowired()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 6.8395

Importance

Changes 4
Bugs 2 Features 0
Metric Value
c 4
b 2
f 0
dl 0
loc 26
ccs 10
cts 14
cp 0.7143
rs 8.439
cc 6
eloc 14
nc 6
nop 1
crap 6.8395

1 Method

Rating   Name   Duplication   Size   Complexity  
A TurnOnAutowireCompilerPass::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 ReflectionClass;
11
use ReflectionMethod;
12
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
use Symfony\Component\DependencyInjection\Definition;
15
use Symplify\DefaultAutowire\DependencyInjection\Definition\DefinitionAnalyzer;
16
17
final class TurnOnAutowireCompilerPass implements CompilerPassInterface
18
{
19
    /**
20
     * @var DefinitionAnalyzer
21
     */
22
    private $definitionAnalyzer;
23
24 2
    public function __construct(DefinitionAnalyzer $definitionAnalyzer)
25
    {
26 2
        $this->definitionAnalyzer = $definitionAnalyzer;
27 2
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function process(ContainerBuilder $containerBuilder)
33
    {
34 2
        foreach ($containerBuilder->getDefinitions() as $definition) {
35 2
            if ($this->definitionAnalyzer->shouldDefinitionBeAutowired($definition)) {
36 2
                $definition->setAutowired(true);
37
            }
38
        }
39 2
    }
40
}
41