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

FormPhoneExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A afterCompile() 12 12 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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