Passed
Push — feature/azure-webapp-pipeline-... ( f7c88d...cc7783 )
by Grant
05:46 queued 13s
created

Skill   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 14
eloc 33
c 1
b 0
f 0
dl 0
loc 105
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A skill_declarations() 0 3 1
A skill_type() 0 3 1
A setIsCultureSkillAttribute() 0 6 2
A classifications() 0 3 1
A setIsFutureSkillAttribute() 0 6 2
A experiences_award() 0 3 1
A experiences_education() 0 3 1
A experiences_personal() 0 3 1
A experience_skills() 0 3 1
A experiences_community() 0 3 1
A experiences_work() 0 3 1
A applicants() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Backpack\CRUD\app\Models\Traits\CrudTrait;
6
use Backpack\CRUD\app\Models\Traits\SpatieTranslatable\HasTranslations;
7
8
/**
9
 * Class Skill
10
 *
11
 * @property int $id
12
 * @property string $name
13
 * @property string $description
14
 * @property int $skill_type_id
15
 * @property boolean $is_culture_skill
16
 * @property boolean $is_future_skill
17
 * @property \Jenssegers\Date\Date $created_at
18
 * @property \Jenssegers\Date\Date $updated_at
19
 *
20
 * @property \App\Models\Lookup\SkillType $skill_type
21
 * @property \Illuminate\Database\Eloquent\Collection $skill_declarations
22
 * @property \Illuminate\Database\Eloquent\Collection $classifications
23
 * @property \App\Models\ExperienceAward|\App\Models\ExperienceCommunity|\App\Models\ExperienceEducation|\App\Models\ExperiencePersonal|\App\Models\ExperienceWork $experience
24
 * @property \Illuminate\Database\Eloquent\Collection $experience_skills
25
 * @property \Illuminate\Database\Eloquent\Collection $applicants
26
 */
27
class Skill extends BaseModel
28
{
29
    use CrudTrait;
30
    use HasTranslations;
31
32
    protected $casts = [
33
        'skill_type_id' => 'int',
34
        'is_culture_skill' => 'boolean',
35
        'is_future_skill' => 'boolean',
36
    ];
37
38
    protected $fillable = [
39
        'name',
40
        'description',
41
        'skill_type_id',
42
        'is_culture_skill',
43
        'is_future_skill',
44
        'classifications'
45
    ];
46
47
    public $translatable = [
48
        'name',
49
        'description',
50
    ];
51
52
    public function skill_type() // phpcs:ignore
53
    {
54
        return $this->belongsTo(\App\Models\Lookup\SkillType::class);
55
    }
56
57
    public function skill_declarations() // phpcs:ignore
58
    {
59
        return $this->hasMany(\App\Models\SkillDeclaration::class);
60
    }
61
62
    public function classifications() // phpcs:ignore
63
    {
64
        return $this->belongsToMany(\App\Models\Classification::class)->withTimestamps();
65
    }
66
67
    // Version 2 application models.
68
69
    public function experiences_work() // phpcs:ignore
70
    {
71
        return $this->morphedByMany(\App\Models\ExperienceWork::class, 'experience', 'experience_skills');
72
    }
73
74
    public function experiences_personal() // phpcs:ignore
75
    {
76
        return $this->morphedByMany(\App\Models\ExperiencePersonal::class, 'experience', 'experience_skills');
77
    }
78
79
    public function experiences_education() // phpcs:ignore
80
    {
81
        return $this->morphedByMany(\App\Models\ExperienceEducation::class, 'experience', 'experience_skills');
82
    }
83
84
    public function experiences_award() // phpcs:ignore
85
    {
86
        return $this->morphedByMany(\App\Models\ExperienceAward::class, 'experience', 'experience_skills');
87
    }
88
89
    public function experiences_community() // phpcs:ignore
90
    {
91
        return $this->morphedByMany(\App\Models\ExperienceCommunity::class, 'experience', 'experience_skills');
92
    }
93
94
    public function experience_skills() // phpcs:ignore
95
    {
96
        return $this->hasMany(\App\Models\ExperienceSkill::class);
97
    }
98
99
    public function applicants() // phpcs:ignore
100
    {
101
        return $this->belongsToMany(\App\Models\Applicant::class, 'applicant_skill');
102
    }
103
104
    /**
105
     * Check for a null "is_culture_skill" and pass false instead.
106
     *
107
     * @param mixed $value Incoming value for the "is_culture_skill" attribute.
108
     *
109
     * @return void
110
     */
111
    public function setIsCultureSkillAttribute($value): void
112
    {
113
        if ($value === null) {
114
            $value = false;
115
        }
116
        $this->attributes['is_culture_skill'] = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
117
    }
118
119
    /**
120
     * Check for a null "is_future_skill" and pass false instead.
121
     *
122
     * @param mixed $value Incoming value for the "is_future_skill" attribute.
123
     *
124
     * @return void
125
     */
126
    public function setIsFutureSkillAttribute($value): void
127
    {
128
        if ($value === null) {
129
            $value = false;
130
        }
131
        $this->attributes['is_future_skill'] = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property attributes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
132
    }
133
}
134