Skip to content

Commit 79ec00c

Browse files
committed
Replace array and str helper
1 parent 86a0892 commit 79ec00c

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

src/MenuBuilder.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Countable;
66
use Illuminate\Contracts\Config\Repository;
7+
use Illuminate\Support\Arr;
78
use Illuminate\View\Factory as ViewFactory;
89

910
class MenuBuilder implements Countable
@@ -351,8 +352,8 @@ public function dropdown($title, \Closure $callback, $order = null, array $attri
351352
if (func_num_args() == 3) {
352353
$arguments = func_get_args();
353354

354-
$title = array_get($arguments, 0);
355-
$attributes = array_get($arguments, 2);
355+
$title = Arr::get($arguments, 0);
356+
$attributes = Arr::get($arguments, 2);
356357

357358
$properties = compact('title', 'attributes');
358359
}
@@ -382,9 +383,9 @@ public function route($route, $title, $parameters = array(), $order = null, $att
382383
$arguments = func_get_args();
383384

384385
return $this->add([
385-
'route' => [array_get($arguments, 0), array_get($arguments, 2)],
386-
'title' => array_get($arguments, 1),
387-
'attributes' => array_get($arguments, 3),
386+
'route' => [Arr::get($arguments, 0), Arr::get($arguments, 2)],
387+
'title' => Arr::get($arguments, 1),
388+
'attributes' => Arr::get($arguments, 3),
388389
]);
389390
}
390391

@@ -428,9 +429,9 @@ public function url($url, $title, $order = 0, $attributes = array())
428429
$arguments = func_get_args();
429430

430431
return $this->add([
431-
'url' => $this->formatUrl(array_get($arguments, 0)),
432-
'title' => array_get($arguments, 1),
433-
'attributes' => array_get($arguments, 2),
432+
'url' => $this->formatUrl(Arr::get($arguments, 0)),
433+
'title' => Arr::get($arguments, 1),
434+
'attributes' => Arr::get($arguments, 2),
434435
]);
435436
}
436437

src/MenuItem.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Contracts\Support\Arrayable as ArrayableContract;
88
use Illuminate\Support\Arr;
99
use Illuminate\Support\Facades\Request;
10+
use Illuminate\Support\Str;
1011

1112
/**
1213
* @property string url
@@ -101,7 +102,7 @@ protected static function setIconAttribute(array $properties)
101102
*/
102103
protected static function getRandomName(array $attributes)
103104
{
104-
return substr(md5(array_get($attributes, 'title', str_random(6))), 0, 5);
105+
return substr(md5(Arr::get($attributes, 'title', Str::random(6))), 0, 5);
105106
}
106107

107108
/**
@@ -161,8 +162,8 @@ public function dropdown($title, \Closure $callback, $order = 0, array $attribut
161162
if (func_num_args() === 3) {
162163
$arguments = func_get_args();
163164

164-
$title = array_get($arguments, 0);
165-
$attributes = array_get($arguments, 2);
165+
$title = Arr::get($arguments, 0);
166+
$attributes = Arr::get($arguments, 2);
166167

167168
$properties = compact('title', 'attributes');
168169
}
@@ -192,9 +193,9 @@ public function route($route, $title, $parameters = array(), $order = 0, $attrib
192193
$arguments = func_get_args();
193194

194195
return $this->add([
195-
'route' => [array_get($arguments, 0), array_get($arguments, 2)],
196-
'title' => array_get($arguments, 1),
197-
'attributes' => array_get($arguments, 3),
196+
'route' => [Arr::get($arguments, 0), Arr::get($arguments, 2)],
197+
'title' => Arr::get($arguments, 1),
198+
'attributes' => Arr::get($arguments, 3),
198199
]);
199200
}
200201

@@ -218,9 +219,9 @@ public function url($url, $title, $order = 0, $attributes = array())
218219
$arguments = func_get_args();
219220

220221
return $this->add([
221-
'url' => array_get($arguments, 0),
222-
'title' => array_get($arguments, 1),
223-
'attributes' => array_get($arguments, 2),
222+
'url' => Arr::get($arguments, 0),
223+
'title' => Arr::get($arguments, 1),
224+
'attributes' => Arr::get($arguments, 2),
224225
]);
225226
}
226227

@@ -507,7 +508,7 @@ public function inactive()
507508
*/
508509
public function getActiveAttribute()
509510
{
510-
return array_get($this->attributes, 'active');
511+
return Arr::get($this->attributes, 'active');
511512
}
512513

513514
/**
@@ -517,7 +518,7 @@ public function getActiveAttribute()
517518
*/
518519
public function getInactiveAttribute()
519520
{
520-
return array_get($this->attributes, 'inactive');
521+
return Arr::get($this->attributes, 'inactive');
521522
}
522523

523524
/**

src/Presenters/Bootstrap/SidebarMenuPresenter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Nwidart\Menus\Presenters\Bootstrap;
44

5+
use Illuminate\Support\Str;
56
use Nwidart\Menus\Presenters\Presenter;
67

78
class SidebarMenuPresenter extends Presenter
@@ -82,7 +83,7 @@ public function getHeaderWrapper($item)
8283
*/
8384
public function getMenuWithDropDownWrapper($item)
8485
{
85-
$id = str_random();
86+
$id = Str::random();
8687

8788
return '
8889
<li class="' . $this->getActiveStateOnChild($item) . ' panel panel-default" id="dropdown">

0 commit comments

Comments
 (0)