Total Complexity | 46 |
Total Lines | 369 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like ProjectEnvironmentFilePerm often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ProjectEnvironmentFilePerm, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
20 | class ProjectEnvironmentFilePerm |
||
21 | { |
||
22 | /** |
||
23 | * @ORM\Id |
||
24 | * @ORM\Column(type="integer") |
||
25 | * @ORM\GeneratedValue(strategy="AUTO") |
||
26 | * |
||
27 | * @var int |
||
28 | */ |
||
29 | private $id; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | * @ORM\Column(name="file_owner", type="string", length=80, nullable=true) |
||
34 | */ |
||
35 | private $fileOwner; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | * @ORM\Column(name="file_group", type="string", length=80, nullable=true) |
||
40 | */ |
||
41 | private $fileGroup; |
||
42 | |||
43 | /** |
||
44 | * @var bool |
||
45 | * @ORM\Column(name="enable_file_permissions", type="boolean", nullable=true) |
||
46 | */ |
||
47 | private $enableFilePermissions; |
||
48 | |||
49 | /** |
||
50 | * @var ProjectEnvironment |
||
51 | * |
||
52 | * @ORM\OneToOne(targetEntity="VersionControl\GitControlBundle\Entity\ProjectEnvironment", mappedBy="projectEnvironmentFilePerm" ) |
||
53 | */ |
||
54 | private $projectEnvironment; |
||
55 | |||
56 | /** |
||
57 | * @var bool |
||
58 | * @ORM\Column(name="permission_owner_read", type="boolean", nullable=true) |
||
59 | */ |
||
60 | private $permissionOwnerRead; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | * @ORM\Column(name="permission_owner_write", type="boolean", nullable=true) |
||
65 | */ |
||
66 | private $permissionOwnerWrite; |
||
67 | |||
68 | /** |
||
69 | * @var bool |
||
70 | * @ORM\Column(name="permission_owner_execute", type="boolean", nullable=true) |
||
71 | */ |
||
72 | private $permissionOwnerExecute; |
||
73 | |||
74 | /** |
||
75 | * @var bool |
||
76 | * @ORM\Column(name="permission_sticky_uid", type="boolean", nullable=true) |
||
77 | */ |
||
78 | private $permissionStickyUid; |
||
79 | |||
80 | /** |
||
81 | * @var bool |
||
82 | * @ORM\Column(name="permission_group_read", type="boolean", nullable=true) |
||
83 | */ |
||
84 | private $permissionGroupRead; |
||
85 | |||
86 | /** |
||
87 | * @var bool |
||
88 | * @ORM\Column(name="permission_group_write", type="boolean", nullable=true) |
||
89 | */ |
||
90 | private $permissionGroupWrite; |
||
91 | |||
92 | /** |
||
93 | * @var bool |
||
94 | * @ORM\Column(name="permission_group_execute", type="boolean", nullable=true) |
||
95 | */ |
||
96 | private $permissionGroupExecute; |
||
97 | |||
98 | /** |
||
99 | * @var bool |
||
100 | * @ORM\Column(name="permission_sticky_gid", type="boolean", nullable=true) |
||
101 | */ |
||
102 | private $permissionStickyGid; |
||
103 | |||
104 | /** |
||
105 | * @var bool |
||
106 | * @ORM\Column(name="permission_other_read", type="boolean", nullable=true) |
||
107 | */ |
||
108 | private $permissionOtherRead; |
||
109 | |||
110 | /** |
||
111 | * @var bool |
||
112 | * @ORM\Column(name="permission_other_write", type="boolean", nullable=true) |
||
113 | */ |
||
114 | private $permissionOtherWrite; |
||
115 | |||
116 | /** |
||
117 | * @var bool |
||
118 | * @ORM\Column(name="permission_other_execute", type="boolean", nullable=true) |
||
119 | */ |
||
120 | private $permissionOtherExecute; |
||
121 | |||
122 | /** |
||
123 | * @var bool |
||
124 | * @ORM\Column(name="permission_sticky_bit", type="boolean", nullable=true) |
||
125 | */ |
||
126 | private $permissionStickyBit; |
||
127 | |||
128 | /** |
||
129 | * Get id. |
||
130 | * |
||
131 | * @return int |
||
132 | */ |
||
133 | public function getId() |
||
134 | { |
||
135 | return $this->id; |
||
136 | } |
||
137 | |||
138 | /** |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getFileOwner() |
||
142 | { |
||
143 | return $this->fileOwner; |
||
144 | } |
||
145 | |||
146 | public function getFileGroup() |
||
147 | { |
||
148 | return $this->fileGroup; |
||
149 | } |
||
150 | |||
151 | public function getPermissionOwner() |
||
152 | { |
||
153 | return $this->permissionOwner; |
||
|
|||
154 | } |
||
155 | |||
156 | public function getPermissionGroup() |
||
157 | { |
||
158 | return $this->permissionGroup; |
||
159 | } |
||
160 | |||
161 | public function getPermissionOther() |
||
162 | { |
||
163 | return $this->permissionOther; |
||
164 | } |
||
165 | |||
166 | public function getPermissionSticky() |
||
167 | { |
||
168 | return $this->permissionSticky; |
||
169 | } |
||
170 | |||
171 | public function getEnableFilePermissions() |
||
172 | { |
||
173 | return $this->enableFilePermissions; |
||
174 | } |
||
175 | |||
176 | public function getProjectEnvironment() |
||
177 | { |
||
178 | return $this->projectEnvironment; |
||
179 | } |
||
180 | |||
181 | public function setFileOwner($fileOwner) |
||
182 | { |
||
183 | $this->fileOwner = $fileOwner; |
||
184 | |||
185 | return $this; |
||
186 | } |
||
187 | |||
188 | public function setFileGroup($fileGroup) |
||
189 | { |
||
190 | $this->fileGroup = $fileGroup; |
||
191 | |||
192 | return $this; |
||
193 | } |
||
194 | |||
195 | public function setEnableFilePermissions($enableFilePermissions) |
||
196 | { |
||
197 | $this->enableFilePermissions = $enableFilePermissions; |
||
198 | |||
199 | return $this; |
||
200 | } |
||
201 | |||
202 | public function setProjectEnvironment(ProjectEnvironment $projectEnvironment) |
||
203 | { |
||
204 | $this->projectEnvironment = $projectEnvironment; |
||
205 | |||
206 | return $this; |
||
207 | } |
||
208 | |||
209 | public function getPermissionOwnerRead() |
||
210 | { |
||
211 | return $this->permissionOwnerRead; |
||
212 | } |
||
213 | |||
214 | public function getPermissionOwnerWrite() |
||
215 | { |
||
216 | return $this->permissionOwnerWrite; |
||
217 | } |
||
218 | |||
219 | public function getPermissionOwnerExecute() |
||
220 | { |
||
221 | return $this->permissionOwnerExecute; |
||
222 | } |
||
223 | |||
224 | public function setPermissionOwnerRead($permissionOwnerRead) |
||
225 | { |
||
226 | $this->permissionOwnerRead = $permissionOwnerRead; |
||
227 | |||
228 | return $this; |
||
229 | } |
||
230 | |||
231 | public function setPermissionOwnerWrite($permissionOwnerWrite) |
||
232 | { |
||
233 | $this->permissionOwnerWrite = $permissionOwnerWrite; |
||
234 | |||
235 | return $this; |
||
236 | } |
||
237 | |||
238 | public function setPermissionOwnerExecute($permissionOwnerExecute) |
||
239 | { |
||
240 | $this->permissionOwnerExecute = $permissionOwnerExecute; |
||
241 | |||
242 | return $this; |
||
243 | } |
||
244 | |||
245 | public function getPermissionStickyUid() |
||
248 | } |
||
249 | |||
250 | public function setPermissionStickyUid($permissionStickyUid) |
||
251 | { |
||
252 | $this->permissionStickyUid = $permissionStickyUid; |
||
253 | |||
254 | return $this; |
||
255 | } |
||
256 | |||
257 | public function getPermissionGroupRead() |
||
258 | { |
||
259 | return $this->permissionGroupRead; |
||
260 | } |
||
261 | |||
262 | public function getPermissionGroupWrite() |
||
263 | { |
||
264 | return $this->permissionGroupWrite; |
||
265 | } |
||
266 | |||
267 | public function getPermissionGroupExecute() |
||
268 | { |
||
269 | return $this->permissionGroupExecute; |
||
270 | } |
||
271 | |||
272 | public function getPermissionStickyGid() |
||
273 | { |
||
274 | return $this->permissionStickyGid; |
||
275 | } |
||
276 | |||
277 | public function getPermissionOtherRead() |
||
278 | { |
||
279 | return $this->permissionOtherRead; |
||
280 | } |
||
281 | |||
282 | public function getPermissionOtherWrite() |
||
283 | { |
||
284 | return $this->permissionOtherWrite; |
||
285 | } |
||
286 | |||
287 | public function getPermissionOtherExecute() |
||
288 | { |
||
289 | return $this->permissionOtherExecute; |
||
290 | } |
||
291 | |||
292 | public function getPermissionStickyBit() |
||
293 | { |
||
294 | return $this->permissionStickyBit; |
||
295 | } |
||
296 | |||
297 | public function setPermissionGroupRead($permissionGroupRead) |
||
298 | { |
||
299 | $this->permissionGroupRead = $permissionGroupRead; |
||
300 | |||
301 | return $this; |
||
302 | } |
||
303 | |||
304 | public function setPermissionGroupWrite($permissionGroupWrite) |
||
305 | { |
||
306 | $this->permissionGroupWrite = $permissionGroupWrite; |
||
307 | |||
308 | return $this; |
||
309 | } |
||
310 | |||
311 | public function setPermissionGroupExecute($permissionGroupExecute) |
||
312 | { |
||
313 | $this->permissionGroupExecute = $permissionGroupExecute; |
||
314 | |||
315 | return $this; |
||
316 | } |
||
317 | |||
318 | public function setPermissionStickyGid($permissionStickyGid) |
||
319 | { |
||
320 | $this->permissionStickyGid = $permissionStickyGid; |
||
321 | |||
322 | return $this; |
||
323 | } |
||
324 | |||
325 | public function setPermissionOtherRead($permissionOtherRead) |
||
326 | { |
||
327 | $this->permissionOtherRead = $permissionOtherRead; |
||
328 | |||
329 | return $this; |
||
330 | } |
||
331 | |||
332 | public function setPermissionOtherWrite($permissionOtherWrite) |
||
337 | } |
||
338 | |||
339 | public function setPermissionOtherExecute($permissionOtherExecute) |
||
340 | { |
||
341 | $this->permissionOtherExecute = $permissionOtherExecute; |
||
342 | |||
343 | return $this; |
||
344 | } |
||
345 | |||
346 | public function setPermissionStickyBit($permissionStickyBit) |
||
347 | { |
||
348 | $this->permissionStickyBit = $permissionStickyBit; |
||
349 | |||
350 | return $this; |
||
351 | } |
||
352 | |||
353 | public function setFileMode($fileMode) |
||
354 | { |
||
355 | //Does nothing |
||
356 | return $this; |
||
357 | } |
||
358 | |||
359 | public function getFileMode() |
||
360 | { |
||
361 | $types = array('Owner', 'Group', 'Other'); |
||
362 | $mode = array(); |
||
363 | |||
389 | } |
||
390 | } |
||
391 |