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

ErrorSerializer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A format() 0 10 1
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