Passed
Push — master ( 0ff158...930e60 )
by Caen
14:22 queued 13s
created

DropdownNavItem   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
eloc 8
c 9
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fromArray() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Framework\Features\Navigation;
6
7
/**
8
 * A navigation item that contains other navigation items.
9
 *
10
 * Unlike a regular navigation items, a dropdown item does not have a route or URL destination.
11
 *
12
 * @see \Hyde\Framework\Testing\Unit\DropdownNavItemTest
13
 */
14
class DropdownNavItem extends NavItem
15
{
16
    /** @var array<NavItem> */
17
    public array $items;
18
    public string $name;
19
    public string $href = '#';
20
21
    public function __construct(string $name, array $items)
22
    {
23
        parent::__construct(null, $name, 999);
24
        $this->items = $items;
25
        $this->name = $name;
26
    }
27
28
    public static function fromArray(string $name, array $items): static
29
    {
30
        return new static($name, $items);
31
    }
32
}
33