Completed
Push — master ( 61a9ce...9b36d9 )
by
unknown
03:37
created

AbstractValidationException::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2.0078

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 8
cp 0.875
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
crap 2.0078
1
<?php
2
3
namespace MediaMonks\RestApi\Exception;
4
5
abstract class AbstractValidationException extends AbstractException implements ExceptionInterface, FieldExceptionInterface
6
{
7
    /**
8
     * AbstractFieldsException constructor.
9
     * @param string $message
10
     * @param string $code
11
     */
12 3
    public function __construct($message, $code)
13
    {
14 3
        $this->message = $message;
15 3
        $this->code = $code;
16 3
    }
17
18
    /**
19
     * @return array
20
     */
21 1
    public function toArray()
22
    {
23
        $return = [
24 1
            'code'    => $this->getCode(),
25 1
            'message' => $this->getMessage(),
26 1
        ];
27 1
        foreach ($this->getFields() as $field) {
28
            $return['fields'][] = $field->toArray();
29 1
        }
30
31 1
        return $return;
32
    }
33
}
34