Passed
Pull Request — master (#300)
by Alexander
06:13 queued 03:06
created

SkipOnEmptyTrait::getSkipOnEmpty()   A

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule\Trait;
6
7
use function is_bool;
8
9
trait SkipOnEmptyTrait
10
{
11 93
    public function skipOnEmpty(bool|callable|null $value): static
12
    {
13 93
        $new = clone $this;
14 93
        $new->skipOnEmpty = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property skipOnEmpty does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
15 93
        return $new;
16
    }
17
18 100
    public function getSkipOnEmpty(): bool|callable|null
19
    {
20 100
        return $this->skipOnEmpty;
21
    }
22
23 94
    private function getSkipOnEmptyOption(): bool
24
    {
25 94
        if (is_bool($this->skipOnEmpty)) {
26 41
            return $this->skipOnEmpty;
27
        }
28
29 53
        return ! ($this->skipOnEmpty === null)
30
31
32
33
         ;
34
    }
35
}
36