Completed
Push — master ( ce9d05...4a4f85 )
by Adam
102:44 queued 91:48
created

Configuration   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 67
Duplicated Lines 23.88 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 91.67%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 9
c 2
b 0
f 0
lcom 2
cbo 1
dl 16
loc 67
ccs 11
cts 12
cp 0.9167
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A automapWithField() 8 8 3
A useLazyAssociation() 0 4 1
A automapWithAssociation() 8 8 4

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
 * Configuration.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        http://www.ipublikuj.eu
7
 * @author         Adam Kadlec http://www.ipublikuj.eu
8
 * @package        iPublikuj:DoctrineBlameable!
9
 * @subpackage     common
10
 * @since          1.0.0
11
 *
12
 * @date           02.01.16
13
 */
14
15
namespace IPub\DoctrineBlameable;
16
17
use Nette;
18
use Nette\Http;
19
20
/**
21
 * Doctrine blameable extension configuration storage
22
 * Store basic extension settings
23
 *
24
 * @package        iPublikuj:DoctrineBlameable!
25
 * @subpackage     common
26
 *
27
 * @author         Adam Kadlec <[email protected]>
28
 */
29
class Configuration extends Nette\Object
30 1
{
31
	/**
32
	 * Flag if use lazy association or not
33
	 *
34
	 * @var bool
35
	 */
36
	public $lazyAssociation = FALSE;
37
38
	/**
39
	 * User entity name
40
	 *
41
	 * @var string
42
	 */
43
	public $userEntity;
44
45
	/**
46
	 * Automatically map filed if not set
47
	 *
48
	 * @var bool
49
	 */
50
	public $automapField = TRUE;
51
52
	/**
53
	 * @param string $userEntity
54
	 * @param bool $lazyAssociation
55
	 * @param bool $automapField
56
	 */
57
	public function __construct($userEntity, $lazyAssociation = FALSE, $automapField = FALSE)
58
	{
59 1
		$this->userEntity = $userEntity;
60 1
		$this->lazyAssociation = $lazyAssociation;
61 1
		$this->automapField = $automapField;
62 1
	}
63
64
	/**
65
	 * @return bool
66
	 */
67 View Code Duplication
	public function automapWithAssociation()
0 ignored issues
show
Duplication introduced by
This method 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...
68
	{
69 1
		if ($this->userEntity !== NULL && class_exists($this->userEntity) && $this->automapField === TRUE) {
70 1
			return TRUE;
71
		}
72
73 1
		return FALSE;
74
	}
75
76
	/**
77
	 * @return bool
78
	 */
79 View Code Duplication
	public function automapWithField()
0 ignored issues
show
Duplication introduced by
This method 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...
80
	{
81 1
		if ($this->userEntity === NULL && $this->automapField === TRUE) {
82 1
			return TRUE;
83
		}
84
85
		return FALSE;
86
	}
87
88
	/**
89
	 * @return bool
90
	 */
91
	public function useLazyAssociation()
92
	{
93 1
		return $this->lazyAssociation === TRUE;
94
	}
95
}
96