Passed
Push — master ( 34594a...aecf28 )
by Koldo
02:06
created

ValidationException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A withField() 0 9 1
A error() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Validator;
6
7
use InvalidArgumentException;
8
9
class ValidationException extends InvalidArgumentException
10
{
11
12
    private $error;
13
14 6
    public static function withField($field, $message): self
15
    {
16 6
        $self = new self($message);
17 6
        $self->error = [
18 6
            'field' => $field,
19 6
            'message' => $message
20
        ];
21
22 6
        return $self;
23
    }
24
25
    public function error(): array
26
    {
27
        return $this->error;
28
    }
29
}
30