ApplicantProfileMenuComposer   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 13
eloc 41
dl 0
loc 58
ccs 22
cts 33
cp 0.6667
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C compose() 0 50 13
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