HasPreset   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 16
ccs 5
cts 7
cp 0.7143
rs 10
c 1
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A preset() 0 11 3
1
<?php
2
3
namespace NovaFlexibleContent\Nova\Fields\TraitsForFlexible;
4
5
use NovaFlexibleContent\Layouts\Preset;
6
7
trait HasPreset
8
{
9
    /**
10
     * Apply a field configuration preset.
11
     */
12 7
    public function preset(Preset|string|array $preset): static
13
    {
14 7
        if (is_string($preset)) {
0 ignored issues
show
introduced by
The condition is_string($preset) is always false.
Loading history...
15
            $preset = new $preset;
16 7
        } elseif (is_array($preset)) {
0 ignored issues
show
introduced by
The condition is_array($preset) is always true.
Loading history...
17
            $preset = Preset::withLayouts($preset);
18
        }
19
20 7
        $preset->handle($this);
21
22 7
        return $this;
23
    }
24
}
25