Completed
Push — master ( e01736...ba6a43 )
by Adam
04:12
created

FormPhoneExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A afterCompile() 0 11 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
namespace IPub\FormPhone\DI;
16
17
use Nette;
18
use Nette\DI;
19
use Nette\PhpGenerator as Code;
20
21
use IPub;
22
use IPub\Phone;
23
24
/**
25
 * Form phone control extension container
26
 *
27
 * @package        iPublikuj:FormPhone!
28
 * @subpackage     DI
29
 *
30
 * @author         Adam Kadlec <[email protected]>
31
 */
32
class FormPhoneExtension extends DI\CompilerExtension
33
{
34
	/**
35
	 * @param Code\ClassType $class
36
	 */
37
	public function afterCompile(Code\ClassType $class)
38
	{
39
		parent::afterCompile($class);
40
41
		$builder = $this->getContainerBuilder();
42
43
		$initialize = $class->methods['initialize'];
44
		$initialize->addBody('IPub\FormPhone\Controls\Phone::register($this->getService(?));', [
45
			$builder->getByType(Phone\Phone::CLASS_NAME)
46
		]);
47
	}
48
}
49