Completed
Pull Request — dev (#319)
by Tristan
07:50
created

ApplicantProfileMenuComposer::compose()   C

Complexity

Conditions 16
Paths 16

Size

Total Lines 68
Code Lines 55

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 272

Importance

Changes 0
Metric Value
eloc 55
dl 0
loc 68
ccs 0
cts 45
cp 0
rs 5.5666
c 0
b 0
f 0
cc 16
nc 16
nop 1
crap 272

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\ViewComposers;
4
5
use Illuminate\View\View;
6
use Illuminate\Support\Facades\Lang;
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Support\Facades\Route;
9
10
class ApplicantProfileMenuComposer
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ApplicantProfileMenuComposer
Loading history...
11
{
12
    /**
13
     * Bind data to the view.
14
     *
15
     * @param  View  $view
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
16
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
17
     */
18
    public function compose(View $view)
19
    {
20
        $profileMenu = [
21
            "about" => [
22
                "active" => false,
23
                "link" => route('profile.about.edit', $view->getData()['applicant']),
24
                "title" => "Go to the About Me section of your profile.",
25
                "label" => "About Me"
26
            ],
27
            "experience" => [
28
                "active" => false,
29
                "link" => route('profile.experience.edit', $view->getData()['applicant']),
30
                "title" => "Go to the Experience section of your profile.",
31
                "label" => "My Experience"
32
            ],
33
            "skills" => [
34
                "active" => false,
35
                "link" => route('profile.skills.edit', $view->getData()['applicant']),
36
                "title" => "Go to the Skills section of your profile.",
37
                "label" => "My Skills"
38
            ],
39
            "references" => [
40
                "active" => false,
41
                "link" => route('profile.references.edit', $view->getData()['applicant']),
42
                "title" => "Go to the References section of your profile.",
43
                "label" => "My References"
44
            ],
45
            "portfolio" => [
46
                "active" => false,
47
                "link" =>route('profile.work_samples.edit', $view->getData()['applicant']),
48
                "title" => "Go to the Portfolio section of your profile.",
49
                "label" => "My Portfolio"
50
            ]
51
        ];
52
53
        //Set active on the proper item
54
        switch(Route::currentRouteName()) {
55
            case('profile.about'):
56
            case('profile.about.edit'):
57
            case('profile.about.update'):
58
                $profileMenu['about']['active'] = true;
59
                break;
60
            case('profile.experience'):
61
            case('profile.experience.edit'):
62
            case('profile.experience.update'):
63
                $profileMenu['experience']['active'] = true;
64
                break;
65
            case('profile.skills'):
66
            case('profile.skills.edit'):
67
            case('profile.skills.update'):
68
                $profileMenu['skills']['active'] = true;
69
                break;
70
            case('profile.references'):
71
            case('profile.references.edit'):
72
            case('profile.references.update'):
73
                $profileMenu['references']['active'] = true;
74
                break;
75
            case('profile.portfolio'):
76
            case('profile.work_samples.edit'):
77
            case('profile.work_samples.update'):
78
                $profileMenu['portfolio']['active'] = true;
79
                break;
80
            default:
81
                //No active menu item
82
                break;
83
        }
84
85
        $view->with('profile_menu', $profileMenu);
86
    }
87
}
88