LinkAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 32
ccs 0
cts 12
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A setTarget() 0 5 1
A __construct() 0 3 1
A toArray() 0 8 1
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