SkillDeclarationBelongsToUserRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
dl 0
loc 18
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A message() 0 3 1
A passes() 0 4 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