Handler::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Exceptions;
4
5
use Exception;
6
use SMartins\JsonHandler\JsonHandler;
7
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
9
class Handler extends ExceptionHandler
10
{
11
    use JsonHandler;
12
13
    /**
14
     * A list of the exception types that are not reported.
15
     *
16
     * @var array
17
     */
18
    protected $dontReport = [
19
        //
20
    ];
21
22
    /**
23
     * A list of the inputs that are never flashed for validation exceptions.
24
     *
25
     * @var array
26
     */
27
    protected $dontFlash = [
28
        'password',
29
        'password_confirmation',
30
    ];
31
32
    /**
33
     * Report or log an exception.
34
     *
35
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
36
     *
37
     * @param  \Exception  $exception
38
     * @return void
39
     */
40
    public function report(Exception $exception)
41
    {
42
        parent::report($exception);
43
    }
44
45
    /**
46
     * Render an exception into an HTTP response.
47
     *
48
     * @param  \Illuminate\Http\Request  $request
49
     * @param  \Exception  $exception
50
     * @return \Illuminate\Http\Response
51
     */
52
    public function render($request, Exception $exception)
53
    {
54
        if ($request->expectsJson()) {
55
            return $this->jsonResponse($exception);
56
        }
57
58
        return parent::render($request, $exception);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::render($request, $exception) also could return the type Illuminate\Http\JsonResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
59
    }
60
}
61