Passed
Push — master ( a77e6b...67a175 )
by Caen
13:07 queued 12s
created

DropdownNavItem   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getItems() 0 3 1
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
use Illuminate\Support\Collection;
8
9
/**
10
 * A navigation item that contains other navigation items.
11
 *
12
 * Unlike a regular navigation items, a dropdown item does not have a route or URL destination.
13
 *
14
 * @see \Hyde\Framework\Testing\Unit\DropdownNavItemTest
15
 */
16
class DropdownNavItem extends NavItem
17
{
18
    /** @var array<NavItem> */
19
    public array $items;
20
    public string $name;
21
    public string $href = '';
22
23
    /** @param array<NavItem> $items */
24
    public function __construct(string $name, array $items)
25
    {
26
        parent::__construct('', $name, 999);
27
        $this->items = $items;
28
        $this->name = $name;
29
    }
30
31
    public static function fromArray(string $name, array $items): static
32
    {
33
        return new static($name, $items);
34
    }
35
36
    public function getItems(): Collection
37
    {
38
        return collect($this->items);
0 ignored issues
show
Bug introduced by
$this->items of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        return collect(/** @scrutinizer ignore-type */ $this->items);
Loading history...
39
    }
40
}
41