ValidationException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
ccs 8
cts 8
cp 1
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 7
    public static function withField($field, $message): self
15
    {
16 7
        $self = new self($message);
17 7
        $self->error = [
18 7
            'field' => $field,
19 7
            'message' => $message
20
        ];
21
22 7
        return $self;
23
    }
24
25 1
    public function error(): array
26
    {
27 1
        return $this->error;
28
    }
29
}
30