MenuController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 13 2
A show() 0 9 1
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Http\Controllers\Back\Menu;
4
5
use Thinktomorrow\Chief\App\Http\Controllers\Controller;
6
use Thinktomorrow\Chief\Site\Menu\Menu;
7
8
class MenuController extends Controller
9
{
10
    public function index()
11
    {
12
        $this->authorize('view-page');
13
14
        $menus = Menu::all();
15
16
        // If there is only one menu, we will show the menu immediately.
17
        if ($menus->count() == 1) {
18
            return $this->show($menus->first()->key());
19
        }
20
21
        return view('chief::admin.menu.index', [
22
            'menus' => $menus,
23
        ]);
24
    }
25
26
    /**
27
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
28
     */
29
    public function show($type)
30
    {
31
        $this->authorize('view-page');
32
33
        $menu = Menu::find($type);
34
35
        return view('chief::admin.menu.show', [
36
            'menuItems' => Menu::tree($type, config('app.fallback_locale')),
0 ignored issues
show
Unused Code introduced by
The call to Thinktomorrow\Chief\Site\Menu\Menu::tree() has too many arguments starting with config('app.fallback_locale'). ( Ignorable by Annotation )

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

36
            'menuItems' => Menu::/** @scrutinizer ignore-call */ tree($type, config('app.fallback_locale')),

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
37
            'menu' => $menu,
38
        ]);
39
    }
40
}
41