phpcollective /
menumaker
| 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
Loading history...
|
|||
| 38 | } |
||
| 39 | |||
| 40 | public function hasChildren() : bool |
||
| 41 | { |
||
| 42 | return $this->children->count() > 0; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |