Configuration   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 72
Duplicated Lines 22.22 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 1
dl 16
loc 72
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        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec <[email protected]>
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
21
/**
22
 * Doctrine blameable extension configuration storage
23
 * Store basic extension settings
24
 *
25
 * @package        iPublikuj:DoctrineBlameable!
26
 * @subpackage     common
27
 *
28
 * @author         Adam Kadlec <[email protected]>
29
 */
30
final class Configuration
31
{
32
	/**
33
	 * Implement nette smart magic
34
	 */
35
	use Nette\SmartObject;
36
37
	/**
38
	 * Flag if use lazy association or not
39
	 *
40
	 * @var bool
41
	 */
42
	public $lazyAssociation = FALSE;
43
44
	/**
45
	 * User entity name
46
	 *
47
	 * @var string|NULL
48
	 */
49
	public $userEntity;
50
51
	/**
52
	 * Automatically map filed if not set
53
	 *
54
	 * @var bool
55
	 */
56
	public $autoMapField = TRUE;
57
58
	/**
59
	 * @param string|NULL $userEntity
60
	 * @param bool $lazyAssociation
61
	 * @param bool $autoMapField
62
	 */
63
	public function __construct(string $userEntity = NULL, bool $lazyAssociation = FALSE, bool $autoMapField = FALSE)
64
	{
65
		$this->userEntity = $userEntity;
66
		$this->lazyAssociation = $lazyAssociation;
67
		$this->autoMapField = $autoMapField;
68
	}
69
70
	/**
71
	 * @return bool
72
	 */
73 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...
74
	{
75
		if ($this->userEntity !== NULL && class_exists($this->userEntity) && $this->autoMapField === TRUE) {
76
			return TRUE;
77
		}
78
79
		return FALSE;
80
	}
81
82
	/**
83
	 * @return bool
84
	 */
85 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...
86
	{
87
		if ($this->userEntity === NULL && $this->autoMapField === TRUE) {
88
			return TRUE;
89
		}
90
91
		return FALSE;
92
	}
93
94
	/**
95
	 * @return bool
96
	 */
97
	public function useLazyAssociation() : bool
98
	{
99
		return $this->lazyAssociation === TRUE;
100
	}
101
}
102