ValidationException::withField()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 1
rs 10
c 0
b 0
f 0
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