Passed
Push — allow-managers-to-edit-job-pos... ( df5250 )
by
unknown
16:16 queued 06:37
created

JobPolicy::edit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
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 5
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\JobPoster;
7
use App\Policies\BasePolicy;
8
9
class JobPolicy extends BasePolicy
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class JobPolicy
Loading history...
10
{
11
12
    /**
13
     * Determine whether the user can view the job poster.
14
     *
15
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
16
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
17
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
18
     */
19
    public function view(User $user, JobPoster $jobPoster)
20
    {
21
        //Anyone can view a published job
22
        //Only the manager that created it can view an unpublished job
23
        return $jobPoster->published ||
24
            $jobPoster->manager->user->id == $user->id;
25
    }
26
27
    /**
28
     * Determine whether the user can create job posters.
29
     *
30
     * @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...
31
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
32
     */
33
    public function create(User $user)
34
    {
35
        //Any manager can create a new job poster
36
        return $user->user_role->name == 'manager';
37
    }
38
39
    /**
40
     * Determine whether the user can update the job poster.
41
     *
42
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
43
     * @param  \App\Models\JobPoster  $jobPoster
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...
44
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
45
     */
46
    public function update(User $user, JobPoster $jobPoster)
47
    {
48
        //Only managers can edit jobs, and only their own
49
        return $user->user_role->name == 'manager' &&
50
            $jobPoster->manager->user->id == $user->id;
51
    }
52
53
    /**
54
     * Determine whether the user can edit the job poster.
55
     *
56
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
57
     * @param  \App\Models\JobPoster  $jobPoster
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...
58
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
59
     */
60
    public function edit(User $user, JobPoster $jobPoster)
61
    {
62
        //Only managers can edit jobs, and only their own
63
        return $user->user_role->name == 'manager' &&
64
            $jobPoster->manager->user->id == $user->id;
65
    }
66
67
    /**
68
     * Determine whether the user can delete the job poster.
69
     *
70
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
71
     * @param  \App\Models\JobPoster  $jobPoster
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...
72
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
73
     */
74
    public function delete(User $user, JobPoster $jobPoster)
0 ignored issues
show
Unused Code introduced by
The parameter $jobPoster is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function delete(User $user, /** @scrutinizer ignore-unused */ JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function delete(/** @scrutinizer ignore-unused */ User $user, JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76
        //
77
    }
78
79
    /**
80
     * Determine whether the user can restore the job poster.
81
     *
82
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
83
     * @param  \App\Models\JobPoster  $jobPoster
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
84
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
85
     */
86
    public function restore(User $user, JobPoster $jobPoster)
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

86
    public function restore(/** @scrutinizer ignore-unused */ User $user, JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $jobPoster is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

86
    public function restore(User $user, /** @scrutinizer ignore-unused */ JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
87
    {
88
        //
89
    }
90
91
    /**
92
     * Determine whether the user can permanently delete the job poster.
93
     *
94
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 2 found
Loading history...
95
     * @param  \App\Models\JobPoster  $jobPoster
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...
96
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
97
     */
98
    public function forceDelete(User $user, JobPoster $jobPoster)
0 ignored issues
show
Unused Code introduced by
The parameter $jobPoster is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
    public function forceDelete(User $user, /** @scrutinizer ignore-unused */ JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

98
    public function forceDelete(/** @scrutinizer ignore-unused */ User $user, JobPoster $jobPoster)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
99
    {
100
        //
101
    }
102
}
103