Skip to content

Commit

Permalink
Replaced deprecated helper functions [Laravel 5.8] (#239)
Browse files Browse the repository at this point in the history
* Replaced deprecated helper function array_except

* Updated PHPDocs and replaced deprecated methods
  • Loading branch information
DevDavido authored and dustingraham committed Mar 26, 2019
1 parent 8c25d58 commit f2ae50c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/Lavary/Menu/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lavary\Menu;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\URL;

class Builder
Expand Down Expand Up @@ -242,7 +243,7 @@ protected static function mergeGroup($new, $old)

$new['class'] = self::formatGroupClass($new, $old);

return array_merge(array_except($old, array('prefix', 'class')), $new);
return array_merge(Arr::except($old, array('prefix', 'class')), $new);
}

/**
Expand Down Expand Up @@ -324,7 +325,7 @@ public function extractAttributes($options = [])
$options = $this->mergeWithLastGroup($options);
}

return array_except($options, $this->reserved);
return Arr::except($options, $this->reserved);
}

/**
Expand Down Expand Up @@ -770,7 +771,7 @@ public static function mergeStatic($new = null, array $old = [])
$attrs['class'] = self::formatGroupClass($attrs, $old);

// Merging new and old array and parse it as a string
return self::attributes(array_merge(array_except($old, array('class')), $attrs));
return self::attributes(array_merge(Arr::except($old, array('class')), $attrs));
}

/**
Expand Down
34 changes: 25 additions & 9 deletions src/Lavary/Menu/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lavary\Menu;

use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Request;

Expand Down Expand Up @@ -63,6 +64,13 @@ class Item
*/
protected $parent;

/**
* Holds link element.
*
* @var Link|null
*/
protected $link;

/**
* Extra information attached to the menu item.
*
Expand Down Expand Up @@ -94,18 +102,17 @@ class Item
/**
* Creates a new Item instance.
*
* @param string $title
* @param string $url
* @param array $attributes
* @param int $parent
* @param Builder $builder
* @param int $id
* @param string $title
* @param array $options
*/
public function __construct($builder, $id, $title, $options)
{
$this->builder = $builder;
$this->id = $id;
$this->title = $title;
$this->nickname = isset($options['nickname']) ? $options['nickname'] : camel_case(Str::ascii($title));
$this->nickname = isset($options['nickname']) ? $options['nickname'] : Str::camel(Str::ascii($title));

$this->attributes = $this->builder->extractAttributes($options);
$this->parent = (is_array($options) && isset($options['parent'])) ? $options['parent'] : null;
Expand All @@ -116,7 +123,7 @@ public function __construct($builder, $id, $title, $options)
} elseif (isset($options['raw']) && true == $options['raw']) {
$path = null;
} else {
$path = array_only($options, array('url', 'route', 'action', 'secure'));
$path = Arr::only($options, array('url', 'route', 'action', 'secure'));
}

if (!is_null($path)) {
Expand All @@ -134,8 +141,9 @@ public function __construct($builder, $id, $title, $options)
/**
* Creates a sub Item.
*
* @param string $title
* @param string $title
* @param string|array $options
* @return Item
*/
public function add($title, $options = '')
{
Expand All @@ -153,6 +161,8 @@ public function add($title, $options = '')
/**
* Add a plain text item.
*
* @param $title
* @param array $options
* @return Item
*/
public function raw($title, array $options = array())
Expand All @@ -163,7 +173,7 @@ public function raw($title, array $options = array())
}

/**
* Insert a seprator after the item.
* Insert a separator after the item.
*
* @param array $attributes
*
Expand Down Expand Up @@ -224,7 +234,7 @@ public function url()
{
// If the item has a link proceed:
if (!is_null($this->link)) {
// If item's link has `href` property explcitly defined
// If item's link has `href` property explicitly defined
// return it
if ($this->link->href) {
return $this->link->href;
Expand All @@ -238,6 +248,7 @@ public function url()
/**
* Prepends text or html to the item.
*
* @param $html
* @return Item
*/
public function prepend($html)
Expand All @@ -250,6 +261,7 @@ public function prepend($html)
/**
* Appends text or html to the item.
*
* @param $html
* @return Item
*/
public function append($html)
Expand All @@ -262,6 +274,7 @@ public function append($html)
/**
* Before text or html to the item.
*
* @param $html
* @return Item
*/
public function before($html)
Expand All @@ -274,6 +287,7 @@ public function before($html)
/**
* After text or html to the item.
*
* @param $html
* @return Item
*/
public function after($html)
Expand Down Expand Up @@ -399,6 +413,7 @@ public function id($id = null)
* Activate the item.
*
* @param Item $item
* @param bool $recursion
*/
public function activate(Item $item = null, $recursion = false)
{
Expand Down Expand Up @@ -427,6 +442,7 @@ public function activate(Item $item = null, $recursion = false)
/**
* Make the item active.
*
* @param null|string $pattern
* @return Item
*/
public function active($pattern = null)
Expand Down

0 comments on commit f2ae50c

Please sign in to comment.