|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* WebHemi. |
|
4
|
|
|
* |
|
5
|
|
|
* PHP version 5.6 |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright 2012 - 2016 Gixx-web (http://www.gixx-web.com) |
|
8
|
|
|
* @license https://opensource.org/licenses/MIT The MIT License (MIT) |
|
9
|
|
|
* |
|
10
|
|
|
* @link http://www.gixx-web.com |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace WebHemi\Data\Entity\AccessManagement; |
|
13
|
|
|
|
|
14
|
|
|
use DateTime; |
|
15
|
|
|
use WebHemi\Data\Entity\DataEntityInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class ResourceEntity. |
|
19
|
|
|
*/ |
|
20
|
|
View Code Duplication |
class ResourceEntity implements DataEntityInterface |
|
|
|
|
|
|
21
|
|
|
{ |
|
22
|
|
|
/** @var int */ |
|
23
|
|
|
private $resourceId; |
|
24
|
|
|
/** @var string */ |
|
25
|
|
|
private $name; |
|
26
|
|
|
/** @var string */ |
|
27
|
|
|
private $title; |
|
28
|
|
|
/** @var string */ |
|
29
|
|
|
private $description; |
|
30
|
|
|
/** @var bool */ |
|
31
|
|
|
private $isReadOnly; |
|
32
|
|
|
/** @var DateTime */ |
|
33
|
|
|
private $dateCreated; |
|
34
|
|
|
/** @var DateTime */ |
|
35
|
|
|
private $dateModified; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Sets the value of the entity identifier. |
|
39
|
|
|
* |
|
40
|
|
|
* @param int $entityId |
|
41
|
|
|
* @return ResourceEntity |
|
42
|
|
|
*/ |
|
43
|
1 |
|
public function setKeyData($entityId) |
|
44
|
|
|
{ |
|
45
|
1 |
|
$this->resourceId = $entityId; |
|
46
|
|
|
|
|
47
|
1 |
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Gets the value of the entity identifier. |
|
52
|
|
|
* |
|
53
|
|
|
* @return int |
|
54
|
|
|
*/ |
|
55
|
2 |
|
public function getKeyData() |
|
56
|
|
|
{ |
|
57
|
2 |
|
return $this->resourceId; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param int $resourceId |
|
62
|
|
|
* |
|
63
|
|
|
* @return ResourceEntity |
|
64
|
|
|
*/ |
|
65
|
4 |
|
public function setResourceId($resourceId) |
|
66
|
|
|
{ |
|
67
|
4 |
|
$this->resourceId = $resourceId; |
|
68
|
|
|
|
|
69
|
4 |
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @return int |
|
74
|
|
|
*/ |
|
75
|
2 |
|
public function getResourceId() |
|
76
|
|
|
{ |
|
77
|
2 |
|
return $this->resourceId; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @param string $name |
|
82
|
|
|
* |
|
83
|
|
|
* @return ResourceEntity |
|
84
|
|
|
*/ |
|
85
|
3 |
|
public function setName($name) |
|
86
|
|
|
{ |
|
87
|
3 |
|
$this->name = $name; |
|
88
|
|
|
|
|
89
|
3 |
|
return $this; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
2 |
|
public function getName() |
|
96
|
|
|
{ |
|
97
|
2 |
|
return $this->name; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* @param string $title |
|
102
|
|
|
* |
|
103
|
|
|
* @return ResourceEntity |
|
104
|
|
|
*/ |
|
105
|
3 |
|
public function setTitle($title) |
|
106
|
|
|
{ |
|
107
|
3 |
|
$this->title = $title; |
|
108
|
|
|
|
|
109
|
3 |
|
return $this; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @return string |
|
114
|
|
|
*/ |
|
115
|
2 |
|
public function getTitle() |
|
116
|
|
|
{ |
|
117
|
2 |
|
return $this->title; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* @param string $description |
|
122
|
|
|
* |
|
123
|
|
|
* @return ResourceEntity |
|
124
|
|
|
*/ |
|
125
|
3 |
|
public function setDescription($description) |
|
126
|
|
|
{ |
|
127
|
3 |
|
$this->description = $description; |
|
128
|
|
|
|
|
129
|
3 |
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* @return string |
|
134
|
|
|
*/ |
|
135
|
2 |
|
public function getDescription() |
|
136
|
|
|
{ |
|
137
|
2 |
|
return $this->description; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @param bool $state |
|
142
|
|
|
* |
|
143
|
|
|
* @return ResourceEntity |
|
144
|
|
|
*/ |
|
145
|
5 |
|
public function setReadOnly($state) |
|
146
|
|
|
{ |
|
147
|
5 |
|
$this->isReadOnly = (bool) $state; |
|
148
|
|
|
|
|
149
|
5 |
|
return $this; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* @return bool |
|
154
|
|
|
*/ |
|
155
|
3 |
|
public function getReadOnly() |
|
156
|
|
|
{ |
|
157
|
3 |
|
return $this->isReadOnly; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
/** |
|
161
|
|
|
* @param DateTime $dateCreated |
|
162
|
|
|
* |
|
163
|
|
|
* @return ResourceEntity |
|
164
|
|
|
*/ |
|
165
|
3 |
|
public function setDateCreated(DateTime $dateCreated) |
|
166
|
|
|
{ |
|
167
|
3 |
|
$this->dateCreated = $dateCreated; |
|
168
|
|
|
|
|
169
|
3 |
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* @return DateTime |
|
174
|
|
|
*/ |
|
175
|
2 |
|
public function getDateCreated() |
|
176
|
|
|
{ |
|
177
|
2 |
|
return $this->dateCreated; |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* @param DateTime $dateModified |
|
182
|
|
|
* |
|
183
|
|
|
* @return ResourceEntity |
|
184
|
|
|
*/ |
|
185
|
3 |
|
public function setDateModified(DateTime $dateModified) |
|
186
|
|
|
{ |
|
187
|
3 |
|
$this->dateModified = $dateModified; |
|
188
|
|
|
|
|
189
|
3 |
|
return $this; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* @return DateTime |
|
194
|
|
|
*/ |
|
195
|
2 |
|
public function getDateModified() |
|
196
|
|
|
{ |
|
197
|
2 |
|
return $this->dateModified; |
|
198
|
|
|
} |
|
199
|
|
|
} |
|
200
|
|
|
|
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.