HasGroupRemovingConfirmation::confirmRemove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 3
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace NovaFlexibleContent\Nova\Fields\TraitsForFlexible;
4
5
use Illuminate\Support\Arr;
6
7
trait HasGroupRemovingConfirmation
8
{
9
10
    /**
11
     * Display confirmation modal before removing group.
12
     */
13
    public function withGroupRemovingConfirmation(?string $modalMessage = null, ?string $yesButtonText = null, ?string $noButtonText = null): static
14
    {
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

15
        return $this->/** @scrutinizer ignore-call */ withMeta([
Loading history...
16
            'confirmRemove'        => true,
17
            'confirmRemoveMessage' => $modalMessage,
18
            'confirmRemoveYes'     => $yesButtonText,
19
            'confirmRemoveNo'      => $noButtonText,
20
        ]);
21
    }
22
23
    /**
24
     * Do not display confirmation modal before removing group.
25
     */
26
    public function withoutGroupRemovingConfirmation(): static
27
    {
28
        Arr::forget($this->meta, [
29
            'confirmRemove',
30
            'confirmRemoveMessage',
31
            'confirmRemoveYes',
32
            'confirmRemoveNo',
33
        ]);
34
35
        return $this;
36
    }
37
38
    /**
39
     * @deprecated
40
     */
41
    public function confirmRemove(?string $label = null, ?string $yes = null, ?string $no = null): static
42
    {
43
        return $this->withGroupRemovingConfirmation($label, $yes, $no);
44
    }
45
46
}
47