AbstractValidationException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 8
c 2
b 0
f 0
dl 0
loc 20
ccs 7
cts 7
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toArray() 0 13 3
1
<?php
2
3
namespace MediaMonks\RestApi\Exception;
4
5
6
abstract class AbstractValidationException extends AbstractException implements ExceptionInterface, FieldExceptionInterface
7
{
8
    public function __construct(protected $message, protected $code)
9
    {
10
        parent::__construct($this->message, $this->code);
11
    }
12 5
13
    public function toArray(): array
14 5
    {
15 5
        $return = [
16 5
            'code'    => $this->getCode(),
17
            'message' => $this->getMessage(),
18
        ];
19
20
        /** @var ExceptionInterface|array $field */
21 3
        foreach ($this->getFields() as $field) {
22
            $return['fields'][] = is_array($field) ? $field : $field->toArray();
23
        }
24 3
25 3
        return $return;
26 3
    }
27
}
28