@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | protected function registerSingleton() |
49 | 49 | { |
50 | - $this->app->singleton('menu', function (Container $app) { |
|
50 | + $this->app->singleton('menu', function(Container $app) { |
|
51 | 51 | return new Menu($app); |
52 | 52 | }); |
53 | 53 | $this->app->alias('menu', MenuContract::class); |
@@ -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 |
@@ -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\Entity\Group; if ($isGroup) $item = $value->item(); else $item = $value; ?> |
|
4 | + <?php $isGroup = $value instanceof \Malezha\Menu\Entity\Group; if ($isGroup) { |
|
5 | + $item = $value->item(); |
|
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> |
@@ -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 |
@@ -6,7 +6,6 @@ |
||
6 | 6 | protected $arrays = []; |
7 | 7 | |
8 | 8 | /** |
9 | - * @param array $arrays,... |
|
10 | 9 | * @throws \RuntimeException |
11 | 10 | */ |
12 | 11 | public function __construct() |
@@ -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 | } |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Malezha\Menu\Tests; |
4 | 4 | |
5 | -use Illuminate\Support\Collection; |
|
6 | 5 | use Malezha\Menu\Contracts\Builder; |
7 | 6 | use Malezha\Menu\Entity\Attributes; |
8 | 7 | use Malezha\Menu\Entity\Item; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $builder = $this->builderFactory(); |
39 | 39 | |
40 | 40 | $item = $builder->add('index', 'Index', '/', ['class' => 'main-menu'], ['class' => 'link'], |
41 | - function (Item $item) { |
|
41 | + function(Item $item) { |
|
42 | 42 | $this->assertAttributeEquals('Index', 'title', $item->getLink()); |
43 | 43 | $item->getLink()->setTitle('Home'); |
44 | 44 | }); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $this->assertInstanceOf(Attributes::class, $activeAttributes); |
104 | 104 | |
105 | - $result = $builder->activeAttributes(function ($attributes) { |
|
105 | + $result = $builder->activeAttributes(function($attributes) { |
|
106 | 106 | $this->assertInstanceOf(Attributes::class, $attributes); |
107 | 107 | |
108 | 108 | return $attributes->get('class'); |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | { |
116 | 116 | $builder = $this->builderFactory(); |
117 | 117 | |
118 | - $group = $builder->group('test', function (Item $item) use ($builder) { |
|
118 | + $group = $builder->group('test', function(Item $item) use ($builder) { |
|
119 | 119 | $this->assertAttributeEquals($builder, 'builder', $item); |
120 | - }, function (Builder $menu) use ($builder) { |
|
120 | + }, function(Builder $menu) use ($builder) { |
|
121 | 121 | $this->assertEquals($builder->activeAttributes()->all(), $menu->activeAttributes()->all()); |
122 | 122 | }); |
123 | 123 | |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | $index = $builder->add('index', 'Index Page', url('/')); |
132 | 132 | $index->getLink()->getAttributes()->push(['class' => 'menu-link']); |
133 | 133 | |
134 | - $builder->group('orders', function ($item) { |
|
134 | + $builder->group('orders', function($item) { |
|
135 | 135 | $item->getAttributes()->push(['class' => 'child-menu']); |
136 | 136 | |
137 | 137 | $link = $item->getLink(); |
138 | 138 | $link->setTitle('Orders'); |
139 | 139 | $link->setUrl('javascript:;'); |
140 | 140 | |
141 | - }, function ($menu) { |
|
141 | + }, function($menu) { |
|
142 | 142 | $menu->add('all', 'All', url('/orders/all')); |
143 | 143 | $menu->add('type_1', 'Type 1', url('/orders/1'), [], ['class' => 'text-color-red']); |
144 | 144 | |
145 | - $menu->add('type_2', 'Type 2', url('/orders/2'), [], [], function ($item) { |
|
145 | + $menu->add('type_2', 'Type 2', url('/orders/2'), [], [], function($item) { |
|
146 | 146 | $item->getLink()->getAttributes()->push(['data-attribute' => 'value']); |
147 | 147 | }); |
148 | 148 | }); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | $builder = $this->builderFactory(); |
159 | 159 | |
160 | 160 | $builder->add('index', 'Index Page', url('/')); |
161 | - $builder->add('login', 'Login', url('/login'))->setDisplayRule(function () { |
|
161 | + $builder->add('login', 'Login', url('/login'))->setDisplayRule(function() { |
|
162 | 162 | return true; |
163 | 163 | }); |
164 | 164 | $builder->add('admin', 'Admin', url('/admin'))->setDisplayRule(false); |
@@ -2,7 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Malezha\Menu\Tests; |
4 | 4 | |
5 | -use Illuminate\Contracts\Routing\UrlGenerator; |
|
6 | 5 | use Malezha\Menu\Entity\Link; |
7 | 6 | |
8 | 7 | class LinkTest extends TestCase |