Completed
Push — master ( a9843f...44c30b )
by
unknown
8s
created

SkrzAutowiringBundle::build()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 27
ccs 17
cts 17
cp 1
rs 8.8571
cc 1
eloc 16
nc 1
nop 1
crap 1
1
<?php
2
namespace Skrz\Bundle\AutowiringBundle;
3
4
use Doctrine\Common\Annotations\AnnotationReader;
5
use Doctrine\Common\Annotations\PhpParser;
6
use Skrz\Bundle\AutowiringBundle\DependencyInjection\ClassMultiMap;
7
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\AutoscanCompilerPass;
8
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\AutowiringCompilerPass;
9
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\ClassMapBuildCompilerPass;
10
use Skrz\Bundle\AutowiringBundle\DependencyInjection\SkrzAutowiringExtension;
11
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\HttpKernel\Bundle\Bundle;
14
15
/**
16
 * @author Jakub Kulhan <[email protected]>
17
 */
18
class SkrzAutowiringBundle extends Bundle
19
{
20
21
	/**
22
	 * {@inheritDoc}
23
	 */
24 1
	public function getContainerExtension()
25
	{
26 1
		if ($this->extension === null) {
27 1
			$this->extension = new SkrzAutowiringExtension();
28 1
		}
29
30 1
		return $this->extension;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression $this->extension; of type Symfony\Component\Depend...xtensionInterface|false adds false to the return on line 30 which is incompatible with the return type declared by the interface Symfony\Component\HttpKe...::getContainerExtension of type Symfony\Component\Depend...ExtensionInterface|null. It seems like you forgot to handle an error condition.
Loading history...
31
	}
32
33 1
	public function build(ContainerBuilder $container)
34
	{
35 1
		$annotationReader = new AnnotationReader;
36 1
		$autoscanClassMap = new ClassMultiMap;
37
38 1
		$container->addCompilerPass(
39 1
			new ClassMapBuildCompilerPass($autoscanClassMap),
40
			PassConfig::TYPE_BEFORE_OPTIMIZATION
41 1
		);
42
43 1
		$container->addCompilerPass(
44 1
			new AutoscanCompilerPass($autoscanClassMap, $annotationReader),
45
			PassConfig::TYPE_BEFORE_OPTIMIZATION
46 1
		);
47
48 1
		$autowiringClassMap = new ClassMultiMap;
49
50 1
		$container->addCompilerPass(
51 1
			new ClassMapBuildCompilerPass($autowiringClassMap),
52
			PassConfig::TYPE_AFTER_REMOVING
53 1
		);
54
55 1
		$container->addCompilerPass(
56 1
			new AutowiringCompilerPass($autowiringClassMap, $annotationReader, new PhpParser),
57
			PassConfig::TYPE_AFTER_REMOVING
58 1
		);
59 1
	}
60
61
}
62