ExceptionFormatter::responseData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace App\Ship\Exceptions\Formatters;
4
5
use Apiato\Core\Exceptions\Formatters\ExceptionsFormatter as CoreExceptionsFormatter;
6
use Exception;
7
use Illuminate\Http\JsonResponse;
8
9
/**
10
 * Class ExceptionFormatter
11
 *
12
 * @author Johannes Schobel <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class ExceptionFormatter extends CoreExceptionsFormatter
16
{
17
18
    /**
19
     * Status Code.
20
     *
21
     * @var  integer
22
     */
23
    CONST STATUS_CODE = 500;
24
25
    /**
26
     * @param \Exception                    $exception
27
     * @param \Illuminate\Http\JsonResponse $response
28
     *
29
     * @return  array
30
     */
31
    public function responseData(Exception $exception, JsonResponse $response)
32
    {
33
        return [
34
            'code'    => $exception->getCode(),
35
            'message' => $exception->getMessage(),
36
            'status_code' => self::STATUS_CODE,
37
        ];
38
    }
39
40
41
    /**
42
     * @param \Exception                    $exception
43
     * @param \Illuminate\Http\JsonResponse $response
44
     *
45
     * @return  mixed
46
     */
47
    function modifyResponse(Exception $exception, JsonResponse $response)
0 ignored issues
show
Best Practice introduced by Mahmoud Zalt
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
48
    {
49
        return $response;
50
    }
51
52
    /**
53
     * @return  int
54
     */
55
    public function statusCode()
56
    {
57
        return self::STATUS_CODE;
58
    }
59
}
60