Completed
Push — master ( 28f29f...4081af )
by Adam
08:00 queued 05:40
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 92.31%

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 1
dl 16
loc 67
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

4 Methods

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