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

BeforeValidationTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getWhen() 0 3 1
A shouldSkipOnError() 0 3 1
A skipOnError() 0 5 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