AlterEvent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_instance() 4 4 1
A set_instance() 4 4 1
A __construct() 6 6 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
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\Render\TemplateResolver;
13
14
use ICanBoogie\Event;
15
use ICanBoogie\Render\TemplateResolver;
16
17
/**
18
 * Event class for the `ICanBoogie\Render\BasicTemplateResolver::alter` event.
19
 *
20
 * Event hooks may use this event to alter the engine collection, or replace it.
21
 *
22
 * @property TemplateResolver $instance
23
 */
24 View Code Duplication
class AlterEvent extends Event
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...
25
{
26
	/**
27
	 * Reference to the target instance.
28
	 *
29
	 * @var TemplateResolver
30
	 */
31
	private $instance;
32
33
	/**
34
	 * @return TemplateResolver
35
	 */
36
	protected function get_instance()
37
	{
38
		return $this->instance;
39
	}
40
41
	/**
42
	 * @param TemplateResolver $template_resolver
43
	 */
44
	protected function set_instance(TemplateResolver $template_resolver)
45
	{
46
		$this->instance = $template_resolver;
47
	}
48
49
	/**
50
	 * Initializes the {@link $instance} property.
51
	 *
52
	 * @param TemplateResolver $target
53
	 */
54
	public function __construct(TemplateResolver &$target)
55
	{
56
		$this->instance = &$target;
57
58
		parent::__construct($target, 'alter');
59
	}
60
}
61