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

SkillDeclarationBelongsToUserRule::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
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