Completed
Push — master ( 67a780...b51deb )
by Adam
02:58
created

Configuration::useLazyAssociation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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
final class Configuration extends Nette\Object
30 1
{
31
	/**
32
	 * Define class name
33
	 */
34
	const CLASS_NAME = __CLASS__;
35
36
	/**
37
	 * Flag if use lazy association or not
38
	 *
39
	 * @var bool
40
	 */
41
	public $lazyAssociation = FALSE;
42
43
	/**
44
	 * User entity name
45
	 *
46
	 * @var string
47
	 */
48
	public $userEntity;
49
50
	/**
51
	 * Automatically map filed if not set
52
	 *
53
	 * @var bool
54
	 */
55
	public $automapField = TRUE;
56
57
	/**
58
	 * @param string $userEntity
59
	 * @param bool $lazyAssociation
60
	 * @param bool $automapField
61
	 */
62
	public function __construct($userEntity, $lazyAssociation = FALSE, $automapField = FALSE)
63
	{
64 1
		$this->userEntity = $userEntity;
65 1
		$this->lazyAssociation = $lazyAssociation;
66 1
		$this->automapField = $automapField;
67 1
	}
68
69
	/**
70
	 * @return bool
71
	 */
72 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...
73
	{
74 1
		if ($this->userEntity !== NULL && class_exists($this->userEntity) && $this->automapField === TRUE) {
75 1
			return TRUE;
76
		}
77
78 1
		return FALSE;
79
	}
80
81
	/**
82
	 * @return bool
83
	 */
84 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...
85
	{
86 1
		if ($this->userEntity === NULL && $this->automapField === TRUE) {
87 1
			return TRUE;
88
		}
89
90
		return FALSE;
91
	}
92
93
	/**
94
	 * @return bool
95
	 */
96
	public function useLazyAssociation()
97
	{
98 1
		return $this->lazyAssociation === TRUE;
99
	}
100
}
101