setPermissionOwnerRead()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
1
<?php
2
/*
3
 * This file is part of the GitControlBundle package.
4
 *
5
 * (c) Paul Schweppe <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace VersionControl\GitControlBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
15
/**
16
 * @ORM\Entity
17
 * @ORM\Entity(repositoryClass="VersionControl\GitControlBundle\Repository\ProjectEnvironmentFilePermRepository")
18
 * @ORM\Table(name="project_environment_file_perm")
19
 */
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;
0 ignored issues
show
Bug introduced by
The property permissionOwner does not exist on VersionControl\GitContro...jectEnvironmentFilePerm. Did you mean permissionOwnerExecute?
Loading history...
154
    }
155
156
    public function getPermissionGroup()
157
    {
158
        return $this->permissionGroup;
0 ignored issues
show
Bug introduced by
The property permissionGroup does not exist on VersionControl\GitContro...jectEnvironmentFilePerm. Did you mean permissionGroupExecute?
Loading history...
159
    }
160
161
    public function getPermissionOther()
162
    {
163
        return $this->permissionOther;
0 ignored issues
show
Bug introduced by
The property permissionOther does not exist on VersionControl\GitContro...jectEnvironmentFilePerm. Did you mean permissionOtherWrite?
Loading history...
164
    }
165
166
    public function getPermissionSticky()
167
    {
168
        return $this->permissionSticky;
0 ignored issues
show
Bug introduced by
The property permissionSticky does not exist on VersionControl\GitContro...jectEnvironmentFilePerm. Did you mean permissionStickyBit?
Loading history...
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()
246
    {
247
        return $this->permissionStickyUid;
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)
333
    {
334
        $this->permissionOtherWrite = $permissionOtherWrite;
335
336
        return $this;
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
364
        $mode['sticky'] = 0;
365
        if ($this->getPermissionStickyUid()) {
366
            $mode['sticky'] += 4;
367
        }
368
        if ($this->getPermissionStickyGid()) {
369
            $mode['sticky'] += 2;
370
        }
371
        if ($this->getPermissionStickyBit()) {
372
            $mode['sticky'] += 1;
373
        }
374
375
        foreach ($types as $type) {
376
            $mode[$type] = 0;
377
            if (call_user_func(array($this, 'getPermission'.$type.'Read'))) {
378
                $mode[$type] += 4;
379
            }
380
            if (call_user_func(array($this, 'getPermission'.$type.'Write'))) {
381
                $mode[$type] += 2;
382
            }
383
            if (call_user_func(array($this, 'getPermission'.$type.'Execute'))) {
384
                $mode[$type] += 1;
385
            }
386
        }
387
388
        return implode('', $mode);
389
    }
390
}
391