HasPreset::preset()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 11
ccs 5
cts 7
cp 0.7143
crap 3.2098
rs 10
c 1
b 0
f 0
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