Completed
Push — FVSv2 ( 1ec6b9...63e0fa )
by Patrick
01:36
created

RoleAPI   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A canEditDept() 0 8 2
A canUpdate() 0 4 1
A canDelete() 0 4 1
A processEntry() 0 4 1
1
<?php
2
class RoleAPI extends VolunteerAPI
3
{
4
    use Processor;
5
6
    public function __construct()
7
    {
8
        parent::__construct('roles', 'short_name');
9
    }
10
11
    protected function canEditDept($request, $deptId)
12
    {
13
        if($this->isVolunteerAdmin($request))
14
        {
15
            return true;
16
        }
17
        return $this->isUserDepartmentLead($deptId, $this->user);
1 ignored issue
show
Bug introduced by
The property user does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18
    }
19
20
    protected function canUpdate($request, $entity)
21
    {
22
        return $this->canEditDept($request, $entity['departmentID']);
23
    }
24
25
    protected function canDelete($request, $entity)
26
    {
27
        return $this->canUpdate($request, $entity);
28
    }
29
30
    protected function processEntry($entry, $request)
31
    {
32
        return $this->processRole($entry, $request);
33
    }
34
}
35