LinkAction::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
ccs 0
cts 5
cp 0
crap 2
rs 10
1
<?php
2
3
namespace InertiaDashboardKit\Adapt\Actions;
4
5
class LinkAction extends AbstractAction
6
{
7
    public string $url;
8
    public string $target = '_self';
9
10
    public function __construct(?string $url = null)
11
    {
12
        $this->url = $url ?? url('/');
13
    }
14
15
    public static function name(): string
16
    {
17
        return 'link';
18
    }
19
20
    public function setTarget(string $target): static
21
    {
22
        $this->target = $target;
23
24
        return $this;
25
    }
26
27
28
29
    public function toArray(): array
30
    {
31
        return array_merge(
32
            parent::toArray(),
33
            [
34
                'type'    => 'link',
35
                'url'     => $this->url,
36
                'target'  => $this->target,
37
            ]
38
        );
39
    }
40
}
41