Completed
Push — master ( 77a1aa...014334 )
by claudio
04:43
created

Planner   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 62.5%

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 6
c 4
b 2
f 0
lcom 1
cbo 2
dl 0
loc 43
ccs 5
cts 8
cp 0.625
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A verifyEmployee() 0 6 2
A verifyCompany() 0 4 1
A groupsManaged() 0 4 1
A verifyGroup() 0 6 2
1
<?php
2
3
namespace plunner;
4
5
6
/**
7
 * Class Planner
8
 *
9
 * @package plunner
10
 * @author Claudio Cardinale <[email protected]>
11
 * @copyright 2015 Claudio Cardinale
12
 * @version 1.0.0
13
 * @property integer $id
14
 * @property string $name
15
 * @property string $email
16
 * @property string $password
17
 * @property integer $company_id
18
 * @property string $remember_token
19
 * @property \Carbon\Carbon $created_at
20
 * @property \Carbon\Carbon $updated_at
21
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groupsManaged
22
 * @property-read \plunner\Company $company
23
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups
24
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings
25
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Calendar[] $calendars
26
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereId($value)
27
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereName($value)
28
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereEmail($value)
29
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner wherePassword($value)
30
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereCompanyId($value)
31
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereRememberToken($value)
32
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereCreatedAt($value)
33
 * @method static \Illuminate\Database\Query\Builder|\plunner\Planner whereUpdatedAt($value)
34
 */
35
class Planner extends Employee
36
{
37
38 6
    public function groupsManaged()
39
    {
40 6
        return $this->HasMany(Group::class);
41
    }
42
43
    /*
44
    * for a planer employee the policyCheckable methods say if the planer can modify or not that part
45
    */
46
47
    /**
48
     * @param Group $group
49
     * @return bool
50
     */
51 4
    public function verifyGroup(Group $group)
52
    {
53 4
        $group = $this->groupsManaged()->where('id', $group->id)->first();
54
55 4
        return (is_object($group) && $group->exists);
56
    }
57
58
    /**
59
     * @param Employee $employee
60
     * @return bool
61
     */
62
    public function verifyEmployee(Employee $employee)
63
    {
64
        $group = $this->groupsManaged()->whereHas('employees',function ($query) use ($employee) {$query->where('employees.id', $employee->id);})->first();
65
66
        return (is_object($group) && $group->exists);
67
    }
68
69
    /**
70
     * @param Company $company
71
     * @return bool
72
     */
73
    public function verifyCompany(Company $company)
74
    {
75
        return false;
76
    }
77
}
78