Passed
Pull Request — master (#57)
by Kyle
08:38
created

ZurbMenuPresenter   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 67
ccs 0
cts 39
cp 0
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getOpenTagWrapper() 0 4 1
A getActiveState() 0 3 2
A getMenuWithDropDownWrapper() 0 8 1
A getDividerWrapper() 0 3 1
A getCloseTagWrapper() 0 3 1
A getMenuWithoutDropdownWrapper() 0 3 1
A getMultiLevelDropdownWrapper() 0 8 1
1
<?php
2
3
namespace KyleMassacre\Menus\Presenters\Foundation;
4
5
use KyleMassacre\Menus\Contracts\MenuItemContract;
6
use KyleMassacre\Menus\Presenters\Presenter;
7
8
class ZurbMenuPresenter extends Presenter
9
{
10
    /**
11
     * {@inheritdoc }
12
     */
13
    public function getOpenTagWrapper(): ?string
14
    {
15
        return  PHP_EOL . '<nav class="custom-main">
16
        <ul class="dropdown menu" data-dropdown-menu>' . PHP_EOL;
17
    }
18
19
    /**
20
     * {@inheritdoc }
21
     */
22
    public function getCloseTagWrapper(): ?string
23
    {
24
        return  PHP_EOL . '</ul></nav>' . PHP_EOL;
25
    }
26
27
    /**
28
     * {@inheritdoc }
29
     */
30
    public function getMenuWithoutDropdownWrapper(MenuItemContract $item): ?string
31
    {
32
        return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->title . '</a></li>';
0 ignored issues
show
Bug Best Practice introduced by
The property title does not exist on KyleMassacre\Menus\Contracts\MenuItemContract. Since you implemented __get, consider adding a @property annotation.
Loading history...
33
    }
34
35
    /**
36
     * {@inheritdoc }
37
     */
38
    public function getActiveState(MenuItemContract $item): ?string
39
    {
40
        return \Request::is($item->getRequest()) ? ' class="is-active"' : null;
41
    }
42
43
    /**
44
     * {@inheritdoc }
45
     */
46
    public function getDividerWrapper(): ?string
47
    {
48
        return '<li class="divider"></li>';
49
    }
50
51
    /**
52
     * {@inheritdoc }
53
     */
54
    public function getMenuWithDropDownWrapper(MenuItemContract $item): ?string
55
    {
56
        return '<li class="dropdown dropdown-primary">
57
                    <a class="dropdown-toggle" href="#">' . $item->title . '</a>
0 ignored issues
show
Bug Best Practice introduced by
The property title does not exist on KyleMassacre\Menus\Contracts\MenuItemContract. Since you implemented __get, consider adding a @property annotation.
Loading history...
58
                    <ul class="menu">
59
                      ' . $this->getChildMenuItems($item) . '
60
                    </ul>
61
                </li>' . PHP_EOL;
62
    }
63
64
    /**
65
     * {@inheritdoc }
66
     */
67
    public function getMultiLevelDropdownWrapper($item): string
68
    {
69
        return '<li>
70
                  <a href="#">' . $item->title . '</a>
71
                  <ul class="menu">
72
                    ' . $this->getChildMenuItems($item) . '
73
                  </ul>
74
                </li>' . PHP_EOL;
75
    }
76
}
77