Completed
Push — master ( 71feda...776f21 )
by claudio
06:53
created

Planner   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 47.37%

Importance

Changes 5
Bugs 2 Features 1
Metric Value
wmc 10
c 5
b 2
f 1
lcom 2
cbo 4
dl 0
loc 89
ccs 9
cts 19
cp 0.4737
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A verifyGroup() 0 6 2
A groupsManaged() 0 4 1
A verifyEmployee() 0 8 2
A verifyCompany() 0 4 1
A verifyCalendar() 0 5 1
A verifyTimeslot() 0 5 1
A verifyMeetingTimeslot() 0 5 1
A verifyMeeting() 0 5 1
1
<?php
2
3
namespace plunner;
4
5
6
/**
7
 * Class Planner
8
 *
9
 * @author Claudio Cardinale <[email protected]>
10
 * @copyright 2015 Claudio Cardinale
11
 * @version 1.0.0
12
 * @package plunner
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 mixed $is_planner
22
 * @property-read \plunner\Company $company
23
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Group[] $groups
24
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Calendar[] $calendars
25
 * @property-read \Illuminate\Database\Eloquent\Collection|\plunner\Meeting[] $meetings
26
 */
27
class Planner extends Employee
28
{
29
30
    /**
31
     * @param Group $group
32
     * @return bool
33
     */
34 38
    public function verifyGroup(Group $group)
35
    {
36 38
        $group = $this->groupsManaged()->where('id', $group->id)->first();
37
38 38
        return (is_object($group) && $group->exists);
39
    }
40
41
    /*
42
    * for a planer employee the policyCheckable methods say if the planer can modify or not that part
43
    */
44
45
    /**
46
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
47
     */
48 40
    public function groupsManaged()
49
    {
50 40
        return $this->groupsManagedRelationship();
51
    }
52
53
    /**
54
     * @param Employee $employee
55
     * @return bool
56
     */
57
    public function verifyEmployee(Employee $employee)
58
    {
59
        $group = $this->groupsManaged()->whereHas('employees', function ($query) use ($employee) {
60
            $query->where('employees.id', $employee->id);
61
        })->first();
62
63
        return (is_object($group) && $group->exists);
64
    }
65
66
    /**
67
     * @param Company $company
68
     * @return bool
69
     */
70
    public function verifyCompany(Company $company)
71
    {
72
        return false;
73
    }
74
75
    /**
76
     * the employee can see a calendar
77
     * @param Calendar $calendar
78
     * @return bool
79
     */
80
    public function verifyCalendar(Calendar $calendar)
81
    {
82
        //TODO implement and test
83
        return false;
84
    }
85
86
    /**
87
     * @param Timeslot $timeslot
88
     * @return bool
89
     */
90
    public function verifyTimeslot(Timeslot $timeslot)
91
    {
92
        //TODO implement and test this
93
        return false;
94
    }
95
96
    /**
97
     * @param MeetingTimeslot $meetingTimeslot
98
     * @return bool
99
     */
100 8
    public function verifyMeetingTimeslot(MeetingTimeslot $meetingTimeslot)
101
    {
102
        //TODO test this
103 8
        return $this->verifyMeeting($meetingTimeslot->meeting);
104
    }
105
106
    /**
107
     * @param Meeting $meeting
108
     * @return bool
109
     */
110 18
    public function verifyMeeting(Meeting $meeting)
111
    {
112
        //TODO test this
113 18
        return $meeting->group->planner_id == $this->id;
114
    }
115
}
116