Completed
Pull Request — dev (#330)
by Josh
06:54
created

ApplicationPolicy::update()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 12
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\JobApplication;
7
use App\Policies\BasePolicy;
8
use Illuminate\Auth\Access\HandlesAuthorization;
9
10
class ApplicationPolicy extends BasePolicy
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicationPolicy
Loading history...
11
{
12
    use HandlesAuthorization;
13
14
    /**
15
     * Determine whether the user can view the jobApplication.
16
     *
17
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
18
     * @param  \App\JobApplication  $jobApplication
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...
19
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
20
     */
21
    public function view(User $user, JobApplication $jobApplication)
22
    {
23
        return $user->user_role->name === "applicant" &&
24
            $user->applicant->id === $jobApplication->applicant_id;
25
    }
26
27
    /**
28
     * Determine whether the user can create jobApplications.
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)
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

33
    public function create(/** @scrutinizer ignore-unused */ User $user)

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...
34
    {
35
        return true;
36
    }
37
38
    /**
39
     * Determine whether the user can update the jobApplication.
40
     *
41
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
42
     * @param  \App\JobApplication  $jobApplication
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...
43
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
44
     */
45
    public function update(User $user, JobApplication $jobApplication)
46
    {
47
        return $user->user_role->name === "applicant" &&
48
            $user->applicant->id === $jobApplication->applicant_id &&
49
            $jobApplication->application_status->name == "draft";
50
    }
51
52
    /**
53
     * Determine whether the user can delete the jobApplication.
54
     *
55
     * @param  \App\Models\User  $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 2 found
Loading history...
56
     * @param  \App\JobApplication  $jobApplication
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...
57
     * @return mixed
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
58
     */
59
    public function delete(User $user, JobApplication $jobApplication)
60
    {
61
        return $user->user_role->name === "applicant" &&
62
            $user->applicant->id === $jobApplication->applicant_id &&
63
            $jobApplication->application_status->name == "draft";
64
    }
65
}
66