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

DropdownNavItem::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 2
dl 0
loc 5
rs 10
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