Passed
Push — feature/manager_api_routes ( 47ca0c )
by Tristan
10:22
created

FrequencyRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A passes() 0 3 1
A message() 0 3 1
1
<?php
2
3
namespace App\Services\Validation\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Illuminate\Support\Facades\Lang;
7
use App\Models\Lookup\Frequency;
8
9
/**
10
 * Validates that value is a valid department id
11
 */
12
class FrequencyRule implements Rule
13
{
14
    /**
15
     * Colaction of valid Frequency ids.
16
     *
17
     * @var Collection
18
     */
19
    protected $validIds;
20
21
    public function __construct()
1 ignored issue
show
Coding Style Documentation introduced by
Missing doc comment for function __construct()
Loading history...
22
    {
23
        $this->validIds = Frequency::all()->pluck('id');
0 ignored issues
show
Documentation Bug introduced by
It seems like App\Models\Lookup\Frequency::all()->pluck('id') of type Illuminate\Support\Collection is incompatible with the declared type App\Services\Validation\Rules\Collection of property $validIds.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
24
25
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
26
27
    public function passes($attribute, $value)
1 ignored issue
show
introduced by
Method \App\Services\Validation\Rules\FrequencyRule::passes() does not have parameter type hint nor @param annotation for its parameter $attribute.
Loading history...
introduced by
Method \App\Services\Validation\Rules\FrequencyRule::passes() does not have parameter type hint nor @param annotation for its parameter $value.
Loading history...
introduced by
Method \App\Services\Validation\Rules\FrequencyRule::passes() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function passes()
Loading history...
28
    {
29
        return $this->validIds->contains($value);
30
31
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
32
33
    public function message()
1 ignored issue
show
introduced by
Method \App\Services\Validation\Rules\FrequencyRule::message() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function message()
Loading history...
34
    {
35
        return Lang::get('validation.invalid_id');
36
    }
37
}
38