Completed
Push — master ( 52970f...c6d773 )
by Tristan
24:57 queued 10:40
created

SkillDeclarationBelongsToUserRule   A

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
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\SkillDeclaration;
10
11
class SkillDeclarationBelongsToUserRule implements Rule
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SkillDeclarationBelongsToUserRule
Loading history...
12
{
13
14
    /**
15
     * This check passes if the $user has ownership of this skill declaration with id=$value
16
     * @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...
17
     * @param  [type] $value     [description]
18
     * @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...
19
     */
20
    public function passes($attribute, $value)
21
    {
22
        return SkillDeclaration::find($value) &&
23
            SkillDeclaration::find($value)->applicant->user->id == Auth::user()->id;
0 ignored issues
show
Bug introduced by
Accessing id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
24
    }
25
26
    public function message()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function message()
Loading history...
27
    {
28
        return Lang::get('validation.user_owns_skill_declaration');
29
    }
30
}
31