Completed
Push — dev ( 39ba5f...0b8cdb )
by Tristan
04:57 queued 04:51
created

LangMenuComposer::compose()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3.512

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 18
ccs 8
cts 13
cp 0.6153
rs 9.8333
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3.512
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 Mcamara\LaravelLocalization\Facades\LaravelLocalization;
8
9
class LangMenuComposer
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class LangMenuComposer
Loading history...
10
{
11
    /**
12
     * Bind data to the view.
13
     *
14
     * @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...
15
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
16
     */
17 12
    public function compose(View $view)
18
    {
19 12
        $locale = LaravelLocalization::getCurrentLocale();
20
21 12
        switch($locale) {
22 12
            case 'en':
23 12
                $linkLocale = 'fr';
24 12
                break;
25
            case 'fr':
26
                $linkLocale = 'en';
27
                break;
28
            default:
29
                $linkLocale = 'fr';
30
                break;
31
        }
32
33 12
        $view->with('lang_menu', Lang::get('common/lang_menu'));
34 12
        $view->with('language_link', LaravelLocalization::getLocalizedURL($linkLocale));
35 12
    }
36
}
37