SkillDeclarationBelongsToUserRule::message()   A
last analyzed

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\Auth;
7
use Illuminate\Support\Facades\Lang;
8
use App\Models\SkillDeclaration;
9
10
class SkillDeclarationBelongsToUserRule implements Rule
11
{
12
13
    /**
14
     * This check passes if the $user has ownership of this skill declaration with id=$value
15
     * @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...
16
     * @param  [type] $value     [description]
17
     * @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...
18
     */
19
    public function passes($attribute, $value)
20
    {
21
        return SkillDeclaration::find($value) &&
22
            SkillDeclaration::find($value)->skillable->user->id == Auth::user()->id;
23
    }
24
25
    public function message()
26
    {
27
        return Lang::get('validation.user_owns_skill_declaration');
28
    }
29
}
30