Passed
Pull Request — master (#317)
by Alexander
27:14 queued 24:41
created

BeforeValidationTrait::skipOnError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Rule\Trait;
6
7
use Closure;
8
use Yiisoft\Validator\ValidationContext;
9
10
trait BeforeValidationTrait
11
{
12 1
    public function skipOnError(bool $value): static
13
    {
14 1
        $new = clone $this;
15 1
        $new->skipOnError = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property skipOnError does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
16 1
        return $new;
17
    }
18
19 95
    public function shouldSkipOnError(): bool
20
    {
21 95
        return $this->skipOnError;
22
    }
23
24
    /**
25
     * @psalm-return Closure(mixed, ValidationContext):bool|null
26
     */
27 94
    public function getWhen(): ?Closure
28
    {
29 94
        return $this->when;
30
    }
31
}
32