Completed
Push — dev ( c3eba7...760621 )
by Tristan
09:29 queued 02:32
created

SkillDeclaration   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
eloc 28
c 0
b 0
f 0
dl 0
loc 58
rs 10
ccs 0
cts 23
cp 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A skill() 0 2 1
A skill_status() 0 2 1
A skill_level() 0 2 1
A applicant() 0 2 1
A work_experiences() 0 7 1
A work_samples() 0 8 1
A references() 0 8 1
1
<?php
2
3
/**
4
 * Created by Reliese Model.
5
 * Date: Thu, 12 Jul 2018 22:39:28 +0000.
6
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
7
8
namespace App\Models;
9
10
/**
11
 * Class SkillDeclaration
12
 *
13
 * @property int $id
14
 * @property int $skill_id
15
 * @property int $skill_status_id
16
 * @property int $skill_level_id
17
 * @property int $applicant_id
18
 * @property string $description
19
 * @property \Jenssegers\Date\Date $created_at
20
 * @property \Jenssegers\Date\Date $updated_at
21
 *
22
 * @property \App\Models\Skill $skill
23
 * @property \App\Models\Lookup\SkillStatus $skill_status
24
 * @property \App\Models\Lookup\SkillLevel $skill_level
25
 * @property \App\Models\Applicant $applicant
26
 * @property \Illuminate\Database\Eloquent\Collection $work_experiences
27
 * @property \Illuminate\Database\Eloquent\Collection $references
28
 * @property \Illuminate\Database\Eloquent\Collection $work_samples
29
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
30
class SkillDeclaration extends BaseModel {
0 ignored issues
show
Coding Style introduced by
Opening brace of a class must be on the line after the definition
Loading history...
31
32
    protected $casts = [
33
        'skill_id' => 'int',
34
        'skill_status_id' => 'int',
35
        'skill_level_id' => 'int',
36
        'applicant_id' => 'int',
37
        'description' => 'string'
38
    ];
39
    protected $fillable = [
40
        'skill_level_id',
41
        'description',
42
    ];
43
44
    public function skill() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function skill()
Loading history...
45
        return $this->belongsTo(\App\Models\Skill::class);
46
    }
47
48
    public function skill_status() {
0 ignored issues
show
Coding Style introduced by
Public method name "SkillDeclaration::skill_status" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function skill_status()
Loading history...
49
        return $this->belongsTo(\App\Models\Lookup\SkillStatus::class);
50
    }
51
52
    public function skill_level() {
0 ignored issues
show
Coding Style introduced by
Public method name "SkillDeclaration::skill_level" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function skill_level()
Loading history...
53
        return $this->belongsTo(\App\Models\Lookup\SkillLevel::class);
54
    }
55
56
    public function applicant() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function applicant()
Loading history...
57
        return $this->belongsTo(\App\Models\Applicant::class);
58
    }
59
60
    public function work_experiences() {
0 ignored issues
show
Coding Style introduced by
Public method name "SkillDeclaration::work_experiences" is not in camel caps format
Loading history...
Coding Style introduced by
Missing doc comment for function work_experiences()
Loading history...
61
        $skill_id = $this->skill->id;
62
        return $this->applicant->work_experiences->filter(
63
            function($work_experience) use ($skill_id) {
64
                //Returns true if $work_experience is connected to a skill
65
                // that matches this skill declaration
66
                return $work_experience->skills->where(id, $skill_id) != null;
0 ignored issues
show
Bug introduced by
The constant App\Models\id was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
67
        });
0 ignored issues
show
Coding Style introduced by
Closing brace indented incorrectly; expected 12 spaces, found 8
Loading history...
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...
68
    }
69
70
    public function references() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function references()
Loading history...
71
        // Retrieve all references belonging to the same applicant and skill
72
        // as this object
73
        $skill_id = $this->skill->id;
74
        return Reference::where('applicant_id', $this->applcant_id)
0 ignored issues
show
Bug introduced by
The property applcant_id does not exist on App\Models\SkillDeclaration. Did you mean applicant_id?
Loading history...
75
            ->whereHas('skills', function($query) use ($skill_id){
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space before opening brace; found 0
Loading history...
76
                $query->where('id', $skill_id);
77
            })->get();
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...
78
    }
79
80
    public function work_samples() {
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function work_samples()
Loading history...
Coding Style introduced by
Public method name "SkillDeclaration::work_samples" is not in camel caps format
Loading history...
81
        // Retrieve all work samples belonging to the same applicant and skill
82
        // as this object
83
        $skill_id = $this->skill->id;
84
        return WorkSample::where('applicant_id', $this->applcant_id)
0 ignored issues
show
Bug introduced by
The property applcant_id does not exist on App\Models\SkillDeclaration. Did you mean applicant_id?
Loading history...
85
            ->whereHas('skills', function($query) use ($skill_id){
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space before opening brace; found 0
Loading history...
86
                $query->where('id', $skill_id);
87
            })->get();
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...
88
    }
89
90
}
91