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

SkipOnEmptyTrait::getSkipOnEmptyOption()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
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