Passed
Push — master ( f8044c...6aa085 )
by Alexander
03:26
created

ErrorSerializer::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 3
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Flugg\Responder\Serializers;
4
5
use Flugg\Responder\Contracts\ErrorSerializer as ErrorSerializerContract;
6
7
/**
8
 * A serializer class responsible for formatting error data.
9
 *
10
 * @package flugger/laravel-responder
11
 * @author  Alexander Tømmerås <[email protected]>
12
 * @license The MIT License
13
 */
14
class ErrorSerializer implements ErrorSerializerContract
15
{
16
    /**
17
     * Format the error data.
18
     *
19
     * @param  string|null $errorCode
20
     * @param  string|null $message
21
     * @param  array|null  $data
22
     * @return array
23
     */
24 1
    public function format(string $errorCode = null, string $message = null, array $data = null): array
25
    {
26
        return [
27
            'error' => [
28 1
                'code' => $errorCode,
29 1
                'message' => $message,
30 1
                'data' => $data,
31
            ],
32
        ];
33
    }
34
}
35