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

WorkExperienceValidator::__construct()   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 1
crap 2
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\WorkExperience;
6
use App\Models\Lookup\VeteranStatus;
7
use App\Models\Lookup\ExperienceLevel;
8
use App\Models\Lookup\ExperienceLevelTranslation;
9
use App\Models\Applicant;
10
use App\Services\Validation\Rules\UniqueApplicantSkillRule;
11
class WorkExperienceValidator
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class WorkExperienceValidator
Loading history...
12
{
13
    
14
    protected $applicant;
15
 
16
    public function __construct(Applicant $applicant)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
17
    {
18
        $this->applicant = $applicant;
19
       
20
    }
21
    public function validate(WorkExperienceValidator $workExperienceValidator)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function validate()
Loading history...
22
    {
23
        $uniqueSkillRule = new UniqueApplicantSkillRule($this->applicant, $workExperienceValidator->id);
0 ignored issues
show
Unused Code introduced by
The assignment to $uniqueSkillRule is dead and can be removed.
Loading history...
Bug Best Practice introduced by
The property id does not exist on App\Services\Validation\WorkExperienceValidator. Did you maybe forget to declare it?
Loading history...
24
        //This array is reset every time because applicants table can change frequently
25
        $applicant_ids = Applicant::all()->pluck('id');
26
        //Validate basic data is filled in
27
        Validator::make($workExperienceValidator->getAttributes(), [  
0 ignored issues
show
Bug introduced by
The method getAttributes() does not exist on App\Services\Validation\WorkExperienceValidator. ( Ignorable by Annotation )

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

27
        Validator::make($workExperienceValidator->/** @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...
28
            'applicant_id' => [
29
                'required',
30
                Rule::in($applicant_ids->toArray()),
31
        ]
32
         
33
        ])->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...
34
    }
35
    
36
}