Completed
Push — task/accessibility-audit-fixes ( 1e0e3b )
by Grant
22s queued 11s
created

UniqueApplicantSkillRule::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Services\Validation\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Hash;
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Support\Facades\Lang;
9
use App\Models\Applicant;
10
11
class UniqueApplicantSkillRule implements Rule
12
{
13
14
    protected $applicant;
1 ignored issue
show
introduced by
Property \App\Services\Validation\Rules\UniqueApplicantSkillRule::$applicant does not have @var annotation.
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
15
    protected $skill_declaration_id;
1 ignored issue
show
introduced by
Property \App\Services\Validation\Rules\UniqueApplicantSkillRule::$skill_declaration_id does not have @var annotation.
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
16
17
    /**
2 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$applicant" missing
Loading history...
Coding Style Documentation introduced by
Doc comment for parameter "$skill_declaration_id" missing
Loading history...
18
     * Create a new rule instance.
19
     *
20
     * @param  App\Models\Applicant  $user
2 ignored issues
show
Bug introduced by
The type App\Services\Validation\Rules\App\Models\Applicant was not found. Did you mean App\Models\Applicant? If so, make sure to prefix the type with \.
Loading history...
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Doc comment for parameter $user does not match actual variable name $applicant
Loading history...
21
     * @return void
22
     */
23 1
    public function __construct(Applicant $applicant, $skill_declaration_id = null)
0 ignored issues
show
introduced by
Method \App\Services\Validation\Rules\UniqueApplicantSkillRule::__construct() does not have parameter type hint nor @param annotation for its parameter $skill_declaration_id.
Loading history...
24
    {
25 1
        $this->applicant = $applicant;
26 1
        $this->skill_declaration_id = $skill_declaration_id;
27 1
    }
28
29
    /**
30
     * This check passes if this applicant has no previous declaration for this skill,
31
     * or if they are updating a previously existing declaration
32
     * @param  [type] $attribute [description]
2 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
Coding Style introduced by
Parameter comment must start with a capital letter
Loading history...
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
33
     * @param  [type] $value     [description]
2 ignored issues
show
Coding Style introduced by
Parameter comment must start with a capital letter
Loading history...
Coding Style Documentation introduced by
Parameter comment must end with a full stop
Loading history...
34
     * @return [type]            [description]
0 ignored issues
show
Documentation Bug introduced by
The doc comment [type] at position 0 could not be parsed: Unknown type name '[' at position 0 in [type].
Loading history...
35
     */
36 1
    public function passes($attribute, $value)
2 ignored issues
show
introduced by
Method \App\Services\Validation\Rules\UniqueApplicantSkillRule::passes() does not have parameter type hint for its parameter $attribute but it should be possible to add it based on @param annotation "[type]".
Loading history...
introduced by
Method \App\Services\Validation\Rules\UniqueApplicantSkillRule::passes() does not have parameter type hint for its parameter $value but it should be possible to add it based on @param annotation "[type]".
Loading history...
introduced by
Method \App\Services\Validation\Rules\UniqueApplicantSkillRule::passes() does not have return type hint for its return value but it should be possible to add it based on @return annotation "[type]".
Loading history...
Coding Style introduced by
Type hint "[type]" missing for $attribute
Loading history...
Coding Style introduced by
Type hint "[type]" missing for $value
Loading history...
37
    {
38 1
        $prev_skills = $this->applicant->skill_declarations->where('skill_id', $value)->pluck('id');
39
40 1
        return $prev_skills->isEmpty() ||
41 1
            ($this->skill_declaration_id != null && $prev_skills->contains($this->skill_declaration_id));
42
    }
43
44
    public function message()
1 ignored issue
show
introduced by
Method \App\Services\Validation\Rules\UniqueApplicantSkillRule::message() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function message()
Loading history...
45
    {
46
        return Lang::get('validation.user_skill_unique');
47
    }
48
}
49