Test Failed
Push — master ( b9b499...9e2edc )
by Adam
12:31
created

FormPhoneExtension::afterCompile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * FormPhoneExtension.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
8
 * @package        iPublikuj:FormPhone!
9
 * @subpackage     DI
10
 * @since          1.0.0
11
 *
12
 * @date           15.12.15
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\FormPhone\DI;
18
19
use Nette;
20
use Nette\DI;
21
use Nette\PhpGenerator as Code;
22
23
use IPub;
24
use IPub\Phone;
25
26
/**
27
 * Form phone control extension container
28
 *
29
 * @package        iPublikuj:FormPhone!
30
 * @subpackage     DI
31
 *
32
 * @author         Adam Kadlec <[email protected]>
33
 */
34 View Code Duplication
final class FormPhoneExtension extends DI\CompilerExtension
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
{
36
	/**
37
	 * {@inheritdoc}
38
	 */
39
	public function afterCompile(Code\ClassType $class)
40
	{
41
		parent::afterCompile($class);
42
43
		$builder = $this->getContainerBuilder();
44
45
		/** @var Code\Method $initialize */
46
		$initialize = $class->methods['initialize'];
47
		$initialize->addBody('IPub\FormPhone\Controls\Phone::register($this->getService(?));', [
48
			$builder->getByType(Phone\Phone::class)
49
		]);
50
	}
51
}
52