@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function make($name, $callback, $type = Builder::UL, $attributes = [], $activeAttributes = []) |
37 | 37 | { |
38 | - if(!is_callable($callback)) { |
|
38 | + if (!is_callable($callback)) { |
|
39 | 39 | throw new \InvalidArgumentException('Argument must be callable'); |
40 | 40 | } |
41 | 41 |
@@ -20,9 +20,9 @@ |
||
20 | 20 | public function canDisplay() |
21 | 21 | { |
22 | 22 | if (is_callable($this->rule)) { |
23 | - return (bool)call_user_func($this->rule); |
|
23 | + return (bool) call_user_func($this->rule); |
|
24 | 24 | } |
25 | 25 | |
26 | - return (bool)$this->rule; |
|
26 | + return (bool) $this->rule; |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | \ No newline at end of file |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function setType($type) |
154 | 154 | { |
155 | - $this->type = (string)$type; |
|
155 | + $this->type = (string) $type; |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | protected function minifyHtmlOutput($html) |
196 | 196 | { |
197 | 197 | $search = array( |
198 | - '/\>[^\S]+/s', // strip whitespaces after tags, except space |
|
199 | - '/[^\S]+\</s', // strip whitespaces before tags, except space |
|
198 | + '/\>[^\S]+/s', // strip whitespaces after tags, except space |
|
199 | + '/[^\S]+\</s', // strip whitespaces before tags, except space |
|
200 | 200 | '/(\s)+/s' // shorten multiple whitespace sequences |
201 | 201 | ); |
202 | 202 |
@@ -227,7 +227,7 @@ |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | - * @param $html |
|
230 | + * @param string $html |
|
231 | 231 | * @return mixed |
232 | 232 | */ |
233 | 233 | protected function minifyHtmlOutput($html) |
@@ -7,7 +7,6 @@ |
||
7 | 7 | use Malezha\Menu\Contracts\Attributes as AttributesContract; |
8 | 8 | use Malezha\Menu\Contracts\Builder as BuilderContract; |
9 | 9 | use Malezha\Menu\Contracts\Group; |
10 | -use Malezha\Menu\Contracts\HasAttributes as HasAttributesContract; |
|
11 | 10 | use Malezha\Menu\Contracts\Item; |
12 | 11 | use Malezha\Menu\Contracts\Link; |
13 | 12 | use Malezha\Menu\Traits\HasAttributes; |
@@ -51,8 +51,7 @@ |
||
51 | 51 | public function buildAttributes($attributes = []) |
52 | 52 | { |
53 | 53 | $attributes = $this->isActive() ? |
54 | - (new MergeAttributes($this->builder->activeAttributes()->all(), $attributes))->merge() : |
|
55 | - $attributes; |
|
54 | + (new MergeAttributes($this->builder->activeAttributes()->all(), $attributes))->merge() : $attributes; |
|
56 | 55 | |
57 | 56 | return $this->attributes->build($attributes); |
58 | 57 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | |
64 | 64 | protected function registerSingleton() |
65 | 65 | { |
66 | - $this->app->singleton('menu.instance', function (Container $app) { |
|
66 | + $this->app->singleton('menu.instance', function(Container $app) { |
|
67 | 67 | return new Menu($app); |
68 | 68 | }); |
69 | 69 | $this->app->alias(MenuContract::class, 'menu.instance'); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $builder = $this->builderFactory(); |
38 | 38 | |
39 | 39 | $item = $builder->add('index', 'Index', '/', ['class' => 'main-menu'], ['class' => 'link'], |
40 | - function (Item $item) { |
|
40 | + function(Item $item) { |
|
41 | 41 | $this->assertAttributeEquals('Index', 'title', $item->getLink()); |
42 | 42 | $item->getLink()->setTitle('Home'); |
43 | 43 | }); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $this->assertInstanceOf(Attributes::class, $activeAttributes); |
103 | 103 | |
104 | - $result = $builder->activeAttributes(function (Attributes $attributes) { |
|
104 | + $result = $builder->activeAttributes(function(Attributes $attributes) { |
|
105 | 105 | $this->assertInstanceOf(Attributes::class, $attributes); |
106 | 106 | |
107 | 107 | return $attributes->get('class'); |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | { |
115 | 115 | $builder = $this->builderFactory(); |
116 | 116 | |
117 | - $group = $builder->group('test', function (Item $item) use ($builder) { |
|
117 | + $group = $builder->group('test', function(Item $item) use ($builder) { |
|
118 | 118 | $this->assertAttributeEquals($builder, 'builder', $item); |
119 | - }, function (Builder $menu) use ($builder) { |
|
119 | + }, function(Builder $menu) use ($builder) { |
|
120 | 120 | $this->assertEquals($builder->activeAttributes()->all(), $menu->activeAttributes()->all()); |
121 | 121 | }); |
122 | 122 | |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | $index = $builder->add('index', 'Index Page', url('/')); |
131 | 131 | $index->getLink()->getAttributes()->push(['class' => 'menu-link']); |
132 | 132 | |
133 | - $builder->group('orders', function (Item $item) { |
|
133 | + $builder->group('orders', function(Item $item) { |
|
134 | 134 | $item->getAttributes()->push(['class' => 'child-menu']); |
135 | 135 | |
136 | 136 | $link = $item->getLink(); |
137 | 137 | $link->setTitle('Orders'); |
138 | 138 | $link->setUrl('javascript:;'); |
139 | 139 | |
140 | - }, function (Builder $menu) { |
|
140 | + }, function(Builder $menu) { |
|
141 | 141 | $menu->add('all', 'All', url('/orders/all')); |
142 | 142 | $menu->add('type_1', 'Type 1', url('/orders/1'), [], ['class' => 'text-color-red']); |
143 | 143 | |
144 | - $menu->add('type_2', 'Type 2', url('/orders/2'), [], [], function (Item $item) { |
|
144 | + $menu->add('type_2', 'Type 2', url('/orders/2'), [], [], function(Item $item) { |
|
145 | 145 | $item->getLink()->getAttributes()->push(['data-attribute' => 'value']); |
146 | 146 | }); |
147 | 147 | }); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $builder = $this->builderFactory(); |
158 | 158 | |
159 | 159 | $builder->add('index', 'Index Page', url('/')); |
160 | - $builder->add('login', 'Login', url('/login'))->setDisplayRule(function () { |
|
160 | + $builder->add('login', 'Login', url('/login'))->setDisplayRule(function() { |
|
161 | 161 | return true; |
162 | 162 | }); |
163 | 163 | $builder->add('admin', 'Admin', url('/admin'))->setDisplayRule(false); |
@@ -1,7 +1,12 @@ |
||
1 | 1 | @if ($menu) |
2 | 2 | <{{ $menu->getType() }}{!! $menu->buildAttributes() !!}> |
3 | 3 | @foreach ($menu->all() as $value) |
4 | - <?php $isGroup = $value instanceof \Malezha\Menu\Contracts\Group; if ($isGroup) $item = $value->getItem(); else $item = $value; ?> |
|
4 | + <?php $isGroup = $value instanceof \Malezha\Menu\Contracts\Group; if ($isGroup) { |
|
5 | + $item = $value->getItem(); |
|
6 | +} else { |
|
7 | + $item = $value; |
|
8 | +} |
|
9 | +?> |
|
5 | 10 | @if($item->canDisplay()) |
6 | 11 | <li{!! $item->buildAttributes() !!}> |
7 | 12 | <a href="{{ $item->getLink()->getUrl() }}"{!! $item->getLink()->buildAttributes() !!}>{!! $item->getLink()->getTitle() !!}</a> |