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

ReferencesValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 15
dl 0
loc 28
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 17 1
1
<?php
2
namespace App\Services\Validation;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
use Illuminate\Support\Facades\Validator;
4
use Illuminate\Validation\Rule;
5
use App\Models\Reference;
6
use App\Services\Validation\Rules\UniqueApplicantSkillRule;
7
class ReferencesValidator
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ReferencesValidator
Loading history...
8
{
9
    
10
    protected $applicant;
11
    protected $relationship_id;
12
    
13
    public function __construct(Applicant $applicant)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
14
    {
15
        $this->applicant = $applicant;
16
        $this->relationship_id = Relationship::all()->pluck('id');
17
    }
18
    public function validate(ReferencesValidator $referencesValidator)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function validate()
Loading history...
19
    {
20
        $uniqueSkillRule = new UniqueApplicantSkillRule($this->applicant, $referencesValidator->id);
0 ignored issues
show
Bug Best Practice introduced by
The property id does not exist on App\Services\Validation\ReferencesValidator. Did you maybe forget to declare it?
Loading history...
Unused Code introduced by
The assignment to $uniqueSkillRule is dead and can be removed.
Loading history...
21
        //This array is reset every time because applicants table can change frequently
22
        $applicant_ids = Applicant::all()->pluck('id');
23
        //Validate basic data is filled in
24
        Validator::make($referencesValidator->getAttributes(), [
0 ignored issues
show
Bug introduced by
The method getAttributes() does not exist on App\Services\Validation\ReferencesValidator. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        Validator::make($referencesValidator->/** @scrutinizer ignore-call */ getAttributes(), [

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
25
            'applicant_id' => [
26
                'required',
27
                Rule::in($applicant_ids->toArray()),      
28
        ],  
29
            'relatonship_id' => [
30
            'required',
31
            Rule::in($this->relationship_id->toArray()),
32
        ]       
33
            
34
        ])->validate();
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
35
    }
36
     
37
}