Passed
Push — master ( 6d6565...6a1810 )
by Caen
03:18 queued 12s
created

NavigationData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 8
rs 10
c 2
b 0
f 0
1
<?php
2
3
namespace Hyde\Framework\Models;
4
5
use Hyde\Framework\Concerns\JsonSerializesArrayable;
6
use Hyde\Framework\Contracts\FrontMatter\Support\NavigationSchema;
7
use Illuminate\Contracts\Support\Arrayable;
8
9
final class NavigationData extends \ArrayObject implements NavigationSchema, Arrayable, \JsonSerializable
10
{
11
    use JsonSerializesArrayable;
12
13
    public ?string $label = null;
14
    public ?string $group = null;
15
    public ?bool $hidden = null;
16
    public ?int $priority = null;
17
18
    public function __construct(?string $label = null, ?string $group = null, ?bool $hidden = null, ?int $priority = null)
19
    {
20
        $this->label = $label;
21
        $this->group = $group;
22
        $this->hidden = $hidden;
23
        $this->priority = $priority;
24
25
        parent::__construct($this->toArray());
26
    }
27
28
    public static function make(array $data): self
29
    {
30
        return new self(
31
            $data['label'] ?? null,
32
            $data['group'] ?? null,
33
            $data['hidden'] ?? null,
34
            $data['priority'] ?? null,
35
        );
36
    }
37
38
    public function toArray(): array
39
    {
40
        return [
0 ignored issues
show
introduced by
The expression return array('label' => ...ty' => $this->priority) returns an array which contains values of type boolean|integer|string which are incompatible with the return type Illuminate\Contracts\Support\TValue mandated by Illuminate\Contracts\Support\Arrayable::toArray().
Loading history...
41
            'label' => $this->label,
42
            'group' => $this->group,
43
            'hidden' => $this->hidden,
44
            'priority' => $this->priority,
45
        ];
46
    }
47
}
48