Passed
Pull Request — dev (#832)
by Tristan
19:00 queued 13:53
created

ApplicantProfileMenuComposer::compose()   C

Complexity

Conditions 13
Paths 13

Size

Total Lines 40
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 19.8615

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 40
ccs 21
cts 32
cp 0.6563
rs 6.6166
c 0
b 0
f 0
cc 13
nc 13
nop 1
crap 19.8615

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
2 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
16
     * @return void
17
     */
18 1
    public function compose(View $view)
0 ignored issues
show
introduced by
Method \App\Http\ViewComposers\ApplicantProfileMenuComposer::compose() does not have return type hint for its return value but it should be possible to add it based on @return annotation "void".
Loading history...
19
    {
20 1
        $profileMenu = Lang::get('applicant/applicant_profile_menu');
21
22 1
        $profileMenu['about']['link'] = route('profile.about.edit', $view->getData()['applicant']);
23 1
        $profileMenu['experience']['link'] = route('profile.experience.edit', $view->getData()['applicant']);
24 1
        $profileMenu['skills']['link'] = route('profile.skills.edit', $view->getData()['applicant']);
25 1
        $profileMenu['references']['link'] = route('profile.references.edit', $view->getData()['applicant']);
26 1
        $profileMenu['portfolio']['link'] = route('profile.work_samples.edit', $view->getData()['applicant']);
27
28
        //Set active on the proper item
29 1
        switch(Route::currentRouteName()) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after SWITCH keyword; 0 found
Loading history...
30 1
            case('profile.about'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
31 1
            case('profile.about.edit'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
32 1
            case('profile.about.update'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
33
                $profileMenu['about']['active'] = true;
34
                break;
35 1
            case('profile.experience'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
36 1
            case('profile.experience.edit'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
37 1
            case('profile.experience.update'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
38
                $profileMenu['experience']['active'] = true;
39
                break;
40 1
            case('profile.skills'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
41 1
            case('profile.skills.edit'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
42
                $profileMenu['skills']['active'] = true;
43
                break;
44 1
            case('profile.references'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
45 1
            case('profile.references.edit'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
46 1
                $profileMenu['references']['active'] = true;
47 1
                break;
48
            case('profile.portfolio'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
49
            case('profile.work_samples.edit'):
0 ignored issues
show
Coding Style introduced by
As per coding-style, case should be followed by a single space.

As per the PSR-2 coding standard, there must be a space after the case keyword, instead of the test immediately following it.

switch (true) {
    case!isset($a):  //wrong
        doSomething();
        break;
    case !isset($b):  //right
        doSomething();
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
50
                $profileMenu['portfolio']['active'] = true;
51
                break;
52
            default:
53
                //No active menu item
54
                break;
55
        }
56
57 1
        $view->with('profile_menu', $profileMenu);
58 1
    }
59
}
60