FormPhoneExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A afterCompile() 0 12 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
final class FormPhoneExtension extends DI\CompilerExtension
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