Passed
Push — master ( b66066...5b471b )
by Smoren
02:41
created

RetrospectiveCheck   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 2
b 0
f 0
dl 0
loc 32
ccs 3
cts 7
cp 0.4286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 2
A isInterrupting() 0 3 1
A setInterrupting() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Validator\Structs;
6
7
use Smoren\Validator\Exceptions\ValidationError;
8
use Smoren\Validator\Interfaces\CheckInterface;
9
10
/**
11
 * @internal
12
 */
13
class RetrospectiveCheck implements CheckInterface
14
{
15
    /**
16
     * {@inheritDoc}
17
     *
18
     * @throws ValidationError if there are previous errors
19
     */
20 3
    public function execute($value, array $previousErrors): void
21
    {
22 3
        if (\count($previousErrors)) {
23 3
            throw ValidationError::fromCheckErrors($value, $previousErrors);
24
        }
25
    }
26
27
    /**
28
     * {@inheritDoc}
29
     *
30
     * @return true
31
     */
32
    public function isInterrupting(): bool
33
    {
34
        return true;
35
    }
36
37
    /**
38
     * @param bool $value
39
     *
40
     * @return static
41
     */
42
    public function setInterrupting(bool $value = true): self
43
    {
44
        return $this;
45
    }
46
}
47