Passed
Push — master ( 8238f8...5ce6e6 )
by Al Amin
05:19
created

MenuItem::hasChildren()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PhpCollective\MenuMaker;
4
5
6
class MenuItem
7
{
8
    public $name;
9
    public $alease;
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