MenuItem   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 15
c 2
b 1
f 0
dl 0
loc 37
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A hasChildren() 0 3 1
A url() 0 3 1
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