Completed
Push — master ( 8d8912...06603f )
by Sebastian
03:51
created

Macros   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 27 1
1
<?php
2
3
namespace App\Services\Navigation\Menu;
4
5
use Spatie\Menu\Laravel\Link;
6
use Spatie\Menu\Laravel\Menu;
7
8
class Macros
9
{
10
    public function register()
11
    {
12
        Menu::macro('back', function () {
13
            return Menu::new()
14
                ->setActiveClass('-active')
15
                ->setActiveFromRequest('/blender');
16
        });
17
18
        Menu::macro('moduleGroup', function ($title) {
19
            return Menu::back()
20
                ->addParentClass('menu_group')
21
                ->setParentAttribute('data-menu-group', fragment("back.nav.{$title}"))
22
                ->registerFilter(function (Link $link) {
23
                    $link->addParentClass('menu_group_item');
24
                });
25
        });
26
27
        Menu::macro('startSecondary', function () {
28
            return $this->registerFilter(function (Link $link) {
0 ignored issues
show
Bug introduced by
The method registerFilter() does not exist on App\Services\Navigation\Menu\Macros. Did you maybe mean register()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
29
                $link->addParentClass('-secondary');
30
            });
31
        });
32
33
        Menu::macro('module', function (string $action, string $name) {
34
            return $this->action("Back\\{$action}", fragment("back.{$name}"));
0 ignored issues
show
Bug introduced by
The method action() does not seem to exist on object<App\Services\Navigation\Menu\Macros>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
        });
36
    }
37
}
38