Completed
Push — master ( 58bfba...7b5b50 )
by Adam
01:59
created

Configuration::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
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 1
final class Configuration
31
{
32
	/**
33
	 * Implement nette smart magic
34
	 */
35 1
	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 1
		$this->userEntity = $userEntity;
66 1
		$this->lazyAssociation = $lazyAssociation;
67 1
		$this->automapField = $automapField;
68 1
	}
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 1
		if ($this->userEntity !== NULL && class_exists($this->userEntity) && $this->automapField === TRUE) {
76 1
			return TRUE;
77
		}
78
79 1
		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 1
		if ($this->userEntity === NULL && $this->automapField === TRUE) {
88 1
			return TRUE;
89
		}
90
91
		return FALSE;
92
	}
93
94
	/**
95
	 * @return bool
96
	 */
97
	public function useLazyAssociation() : bool
98
	{
99 1
		return $this->lazyAssociation === TRUE;
100
	}
101
}
102