Passed
Push — feature/delete_items ( abdbb3...c1e89b )
by Tristan
09:18
created

ApplicantHasRelationRule::passes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

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 1
nc 1
nop 2
crap 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
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 ApplicantHasRelationRule implements Rule
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicantHasRelationRule
Loading history...
12
{
13
14
    protected $applicant;
15
    protected $relation;
16
17
    /**
18
     * Create a new rule instance.
19
     *
20
     * @param  App\Models\Applicant  $applicant
0 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 introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
21
     * @param  string  $relation
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 15 spaces after parameter type; 2 found
Loading history...
22
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
23
     */
24
    public function __construct($applicant, $relation)
25
    {
26
        $this->applicant = $applicant;
27
        $this->relation = $relation;
28
    }
29
30
    /**
31
     * This check passes if the model's relation contains an object whose id=$value
32
     * @param  [type] $attribute [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...
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
33
     * @param  [type] $value     [description]
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...
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
35
     */
36
    public function passes($attribute, $value)
37
    {
38
        return $this->applicant->getRelationValue($this->relation)
39
            ->pluck('id')->contains($value);
40
    }
41
42
    public function message()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function message()
Loading history...
43
    {
44
        return Lang::get('validation.custom.applicant_has_relation');
45
    }
46
}
47