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

Configuration::automapWithField()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 3.3332

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
loc 8
ccs 2
cts 3
cp 0.6667
rs 9.4286
cc 3
eloc 4
nc 2
nop 0
crap 3.3332
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