Passed
Push — master ( dd9897...8de557 )
by Smoren
02:06
created

RetrospectiveCheck   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 5
c 1
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
namespace Smoren\Validator\Structs;
4
5
use Smoren\Validator\Exceptions\ValidationError;
6
use Smoren\Validator\Interfaces\CheckInterface;
7
8
class RetrospectiveCheck implements CheckInterface
9
{
10
    /**
11
     * {@inheritDoc}
12
     *
13
     * @throws ValidationError if there are previous errors
14
     */
15 3
    public function execute($value, array $previousErrors): void
16
    {
17 3
        if (\count($previousErrors)) {
18 3
            throw ValidationError::fromCheckErrors($value, $previousErrors);
19
        }
20
    }
21
22
    /**
23
     * {@inheritDoc}
24
     *
25
     * @return true
26
     */
27
    public function isInterrupting(): bool
28
    {
29
        return true;
30
    }
31
32
    /**
33
     * @param bool $value
34
     *
35
     * @return static
36
     */
37
    public function setInterrupting(bool $value = true): self
38
    {
39
        return $this;
40
    }
41
}
42