ApplicantProfileMenuComposer::compose()   C
last analyzed

Complexity

Conditions 13
Paths 13

Size

Total Lines 50
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 19.2573

Importance

Changes 0
Metric Value
eloc 40
dl 0
loc 50
ccs 22
cts 33
cp 0.6667
rs 6.6166
c 0
b 0
f 0
cc 13
nc 13
nop 1
crap 19.2573

How to fix   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
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
11
{
12
    /**
13
     * Bind data to the view.
14
     *
15
     * @param  View  $view
16
     * @return void
17
     */
18 1
    public function compose(View $view)
19
    {
20 1
        $profileMenu = Lang::get('applicant/applicant_profile_menu');
21
22 1
        $profileMenu['items']['about']['link'] = route('profile.about.edit', $view->getData()['applicant']);
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

22
        $profileMenu['items']['about']['link'] = /** @scrutinizer ignore-call */ route('profile.about.edit', $view->getData()['applicant']);
Loading history...
23 1
        $profileMenu['items']['experience']['link'] = route('profile.experience.edit', $view->getData()['applicant']);
24 1
        $profileMenu['items']['skills']['link'] = route('profile.skills.edit', $view->getData()['applicant']);
25 1
        $profileMenu['items']['skills-old']['link'] = route('profile.skills-old.edit', $view->getData()['applicant']);
26 1
        $profileMenu['items']['references']['link'] = route('profile.references.edit', $view->getData()['applicant']);
27
        $profileMenu['items']['portfolio']['link'] = route('profile.work_samples.edit', $view->getData()['applicant']);
28
29 1
        // Set archive variable to group sidebar
30 1
        $profileMenu['items']['about']['archive'] = true;
31 1
        $profileMenu['items']['experience']['archive'] = false;
32 1
        $profileMenu['items']['skills-old']['archive'] = true;
33
        $profileMenu['items']['references']['archive'] = true;
34
        $profileMenu['items']['portfolio']['archive'] = true;
35 1
36 1
        // Set active on the proper item
37 1
        switch (Route::currentRouteName()) {
38
            case ('profile.about'):
39
            case ('profile.about.edit'):
40 1
                $profileMenu['items']['about']['active'] = true;
41 1
                break;
42
            case ('profile.experience'):
43
            case ('profile.experience.edit'):
44 1
                $profileMenu['items']['experience']['active'] = true;
45 1
                break;
46 1
            case ('profile.skills'):
47 1
            case ('profile.skills.edit'):
48
                $profileMenu['items']['skills']['active'] = true;
49
                break;
50
            case ('profile.skills-old'):
51
            case ('profile.skills-old.edit'):
52
                $profileMenu['items']['skills-old']['active'] = true;
53
                break;
54
            case ('profile.references'):
55
            case ('profile.references.edit'):
56
                $profileMenu['items']['references']['active'] = true;
57 1
                break;
58 1
            case ('profile.portfolio'):
59
            case ('profile.work_samples.edit'):
60
                $profileMenu['items']['portfolio']['active'] = true;
61
                break;
62
            default:
63
                // No active menu item
64
                break;
65
        }
66
67
        $view->with('profile_menu', $profileMenu);
68
    }
69
}
70