Completed
Push — master ( 52970f...c6d773 )
by Tristan
24:57 queued 10:40
created

ScreeningPlanPolicy::view()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Policies;
4
5
use App\Models\User;
6
use App\Models\ScreeningPlan;
7
8
class ScreeningPlanPolicy extends BasePolicy
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ScreeningPlanPolicy
Loading history...
9
{
10
    /**
11
     * Determine whether the user can view the screeningPlan.
12
     * Only the manager for the corresponding job can view it.
13
     *
14
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter type; 2 found
Loading history...
15
     * @param  \App\Models\ScreeningPlan  $screeningPlan
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
16
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
17
     */
18
    public function view(User $user, ScreeningPlan $screeningPlan)
19
    {
20
        return $user->hasRole('manager') &&
21
            $screeningPlan->job_poster->manager->user->is($user);
22
    }
23
24
    /**
25
     * Determine whether the user can create screeningPlans.
26
     * Any manager can create a screening plan for a job they own.
27
     *
28
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
29
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
30
     */
31
    public function create(User $user)
32
    {
33
        return $user->hasRole('manager');
34
    }
35
36
    /**
37
     * Determine whether the user can update the screeningPlan.
38
     *
39
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter type; 2 found
Loading history...
40
     * @param  \App\Models\ScreeningPlan  $screeningPlan
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
41
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
42
     */
43
    public function update(User $user, ScreeningPlan $screeningPlan)
44
    {
45
        return $user->hasRole('manager') &&
46
            $screeningPlan->job_poster->manager->user->is($user);
47
    }
48
49
    /**
50
     * Determine whether the user can delete the screeningPlan.
51
     *
52
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter type; 2 found
Loading history...
53
     * @param  \App\Models\ScreeningPlan  $screeningPlan
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
54
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
55
     */
56
    public function delete(User $user, ScreeningPlan $screeningPlan)
57
    {
58
        return $user->hasRole('manager') &&
59
            $screeningPlan->job_poster->manager->user->is($user);
60
    }
61
}
62