Passed
Push — master ( 151935...bf98f6 )
by Smoren
02:25
created

RetrospectiveCheck   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 2
b 0
f 0
dl 0
loc 42
ccs 3
cts 9
cp 0.3333
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 2
A getName() 0 3 1
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
    protected const NAME = 'retrospective';
16
17
    /**
18
     * {@inheritDoc}
19
     *
20
     * @throws ValidationError if there are previous errors
21
     */
22 3
    public function execute($value, array $previousErrors): void
23
    {
24 3
        if (\count($previousErrors)) {
25 3
            throw ValidationError::fromCheckErrors($value, $previousErrors);
26
        }
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     *
32
     * @return true
33
     */
34
    public function isInterrupting(): bool
35
    {
36
        return true;
37
    }
38
39
    /**
40
     * @param bool $value
41
     *
42
     * @return static
43
     */
44
    public function setInterrupting(bool $value = true): self
45
    {
46
        return $this;
47
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public function getName(): string
53
    {
54
        return static::NAME;
55
    }
56
}
57