Issues (54)

src/MenuItem.php (1 issue)

1
<?php
2
3
namespace PhpCollective\MenuMaker;
4
5
6
class MenuItem
7
{
8
    public $name;
9
    public $alias;
10
    public $routes;
11
    public $link;
12
    public $icon;
13
    public $class;
14
    public $attr;
15
    public $active;
16
    public $children;
17
18
    /**
19
     * Create a new MenuItem instance.
20
     *
21
     * @param  array  $attributes
22
     * @return void
23
     */
24
    public function __construct(array $attributes = [])
25
    {
26
        foreach ($attributes as $key => $value)
27
        {
28
            if(property_exists($this, $key))
29
            {
30
                $this->{$key} = $value;
31
            }
32
        }
33
    }
34
35
    public function url() : string
36
    {
37
        return url($this->link);
0 ignored issues
show
Bug Best Practice introduced by
The expression return url($this->link) could return the type Illuminate\Contracts\Routing\UrlGenerator which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
38
    }
39
40
    public function hasChildren() : bool
41
    {
42
        return $this->children->count() > 0;
43
    }
44
}
45