Completed
Push — master ( 034dff...628390 )
by
unknown
10:02
created

AbstractValidationException::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
crap 2
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 5
    public function __construct($message, $code)
13
    {
14 5
        $this->message = $message;
15 5
        $this->code = $code;
16 5
    }
17
18
    /**
19
     * @return array
20
     */
21 3
    public function toArray()
22
    {
23
        $return = [
24 3
            'code'    => $this->getCode(),
25 3
            'message' => $this->getMessage(),
26 3
        ];
27 3
        foreach ($this->getFields() as $field) {
28 1
            $return['fields'][] = $field->toArray();
29 3
        }
30
31 3
        return $return;
32
    }
33
}
34