Completed
Push — master ( caf0ee...42fac9 )
by Jeroen
14:00 queued 08:34
created

AdminLte   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 89.47%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 47
ccs 17
cts 19
cp 0.8947
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A menu() 0 8 2
A buildMenu() 0 12 2
A buildFilters() 0 4 1
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use Illuminate\Contracts\Container\Container;
7
use JeroenNoten\LaravelAdminLte\Menu\Builder;
8
use JeroenNoten\LaravelAdminLte\Events\BuildingMenu;
9
10
class AdminLte
11
{
12
    protected $menu;
13
14
    protected $filters;
15
16
    protected $events;
17
18
    protected $container;
19
20 1
    public function __construct(
21
        array $filters,
22
        Dispatcher $events,
23
        Container $container
24
    ) {
25 1
        $this->filters = $filters;
26 1
        $this->events = $events;
27 1
        $this->container = $container;
28 1
    }
29
30 1
    public function menu()
31
    {
32 1
        if (! $this->menu) {
33 1
            $this->menu = $this->buildMenu();
34 1
        }
35
36 1
        return $this->menu;
37
    }
38
39 1
    protected function buildMenu()
40
    {
41 1
        $builder = new Builder($this->buildFilters());
42
43 1
        if (method_exists($this->events, 'dispatch')) {
44
            $this->events->dispatch(new BuildingMenu($builder));
45
        } else {
46 1
            $this->events->fire(new BuildingMenu($builder));
0 ignored issues
show
Bug introduced by
The method fire() does not seem to exist on object<Illuminate\Contracts\Events\Dispatcher>.

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...
47
        }
48
49 1
        return $builder->menu;
50
    }
51
52 1
    protected function buildFilters()
53
    {
54 1
        return array_map([$this->container, 'make'], $this->filters);
55
    }
56
}
57