AbstractValidationException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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