Passed
Push — task/application-profile-react... ( 95a834...f06e77 )
by Yonathan
08:39
created

Experience::getExperienceInstance()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 21
rs 9.0444
c 0
b 0
f 0
cc 6
nc 6
nop 2
1
<?php
2
3
namespace App\Models;
4
5
use App\Models\BaseModel;
6
use App\Models\ExperienceAward;
7
use App\Models\ExperienceCommunity;
8
use App\Models\ExperienceEducation;
9
use App\Models\ExperiencePersonal;
10
use App\Models\ExperienceSkill;
11
use App\Models\ExperienceWork;
12
13
class Experience extends BaseModel
14
{
15
    public function getExperienceInstance(string $experience_type, int $experience_id)
16
    {
17
        $experience = null;
18
        switch ($experience_type) {
19
            case 'experience_work':
20
                $experience = ExperienceWork::find($experience_id);
21
                break;
22
            case 'experience_award':
23
                $experience = ExperienceAward::find($experience_id);
24
                break;
25
            case 'experience_community':
26
                $experience = ExperienceCommunity::find($experience_id);
27
                break;
28
            case 'experience_education':
29
                $experience = ExperienceEducation::find($experience_id);
30
                break;
31
            case 'experience_personal':
32
                $experience = ExperiencePersonal::find($experience_id);
33
                break;
34
        }
35
        return $experience;
36
    }
37
    public function getApplicantInstance(object $experience)
38
    {
39
        $applicant = null;
40
        switch ($experience->experienceable_type) {
41
            case 'applicant':
42
                $applicant = $experience->experienceable;
43
                break;
44
            case 'application':
45
                $applicant = $experience->experienceable->applicant;
46
                break;
47
        }
48
        return $applicant;
49
    }
50
}
51