HasLayoutsMenu::useDefaultLayoutsMenu()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace NovaFlexibleContent\Nova\Fields\TraitsForFlexible;
4
5
trait HasLayoutsMenu
6
{
7
    /**
8
     * Initialise trait in Flexible constructor.
9
     */
10 15
    protected function initializeHasLayoutsMenu(): void
11
    {
12 15
        $this->useDefaultLayoutsMenu();
13
    }
14
15
    /**
16
     * Set the dropdown button configuration.
17
     */
18 15
    public function layoutsMenuButton(?string $buttonText = null, array $options = []): static
19
    {
20 15
        return $this->withMeta([
0 ignored issues
show
Bug introduced by
It seems like withMeta() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
        return $this->/** @scrutinizer ignore-call */ withMeta([
Loading history...
21 15
            'button'        => $buttonText,
22 15
            'buttonOptions' => $options,
23 15
        ]);
24
    }
25
26
    /**
27
     * Set custom dropdown menu component.
28
     */
29 15
    public function layoutsMenu(string $component = '', array $componentOptions = []): static
30
    {
31 15
        return $this->withMeta(['menu' => ['component' => $component, 'data' => $componentOptions]]);
32
    }
33
34
    /**
35
     * Set custom dropdown menu component.
36
     */
37 15
    public function useDefaultLayoutsMenu(array $componentOptions = []): static
38
    {
39 15
        return $this->layoutsMenu('FlexibleDefaultMenu', $componentOptions);
40
    }
41
42
    /**
43
     * Set custom dropdown menu component.
44
     */
45
    public function useSearchableLayoutsMenu(array $componentOptions = []): static
46
    {
47
        return $this->layoutsMenu('FlexibleSearchableMenu', $componentOptions);
48
    }
49
50
    /**
51
     * @deprecated
52
     */
53
    public function button(?string $label = null): static
54
    {
55
        return $this->layoutsMenuButton($label);
56
    }
57
58
    /**
59
     * @deprecated
60
     */
61
    public function menu(string $component, array $data = []): static
62
    {
63
        return $this->layoutsMenu($component, $data);
64
    }
65
}
66