SkrzAutowiringBundle::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 9.4285
cc 1
eloc 9
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\AutowiringCompilerPass;
8
use Skrz\Bundle\AutowiringBundle\DependencyInjection\Compiler\ClassMapBuildCompilerPass;
9
use Skrz\Bundle\AutowiringBundle\DependencyInjection\SkrzAutowiringExtension;
10
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
11
use Symfony\Component\DependencyInjection\ContainerBuilder;
12
use Symfony\Component\HttpKernel\Bundle\Bundle;
13
14
/**
15
 * @author Jakub Kulhan <[email protected]>
16
 */
17
class SkrzAutowiringBundle extends Bundle
18
{
19
20
	/**
21
	 * {@inheritDoc}
22
	 */
23 1
	public function getContainerExtension()
24
	{
25 1
		if ($this->extension === null) {
26 1
			$this->extension = new SkrzAutowiringExtension();
27
		}
28
29 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 29 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...
30
	}
31
32 1
	public function build(ContainerBuilder $container)
33
	{
34 1
		$annotationReader = new AnnotationReader();
35 1
		$autowiringClassMap = new ClassMultiMap($container);
36
37 1
		$container->addCompilerPass(
38 1
			new ClassMapBuildCompilerPass($autowiringClassMap),
39 1
			PassConfig::TYPE_OPTIMIZE
40
		);
41
42 1
		$container->addCompilerPass(
43 1
			new AutowiringCompilerPass($autowiringClassMap, $annotationReader, new PhpParser()),
44 1
			PassConfig::TYPE_OPTIMIZE
45
		);
46 1
	}
47
48
}
49