Handler::report()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Exceptions;
4
5
use Exception;
6
use Illuminate\Auth\AuthenticationException;
7
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
9
class Handler extends ExceptionHandler
10
{
11
    /**
12
     * A list of the exception types that should not be reported.
13
     *
14
     * @var array
15
     */
16
    protected $dontReport = [
17
        \Illuminate\Auth\AuthenticationException::class,
18
        \Illuminate\Auth\Access\AuthorizationException::class,
19
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
20
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
21
        \Illuminate\Validation\ValidationException::class,
22
    ];
23
24
    /**
25
     * Report or log an exception.
26
     *
27
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
28
     *
29
     * @param  \Exception  $exception
30
     * @return void
31
     */
32
    public function report(Exception $exception)
33
    {
34
        parent::report($exception);
35
    }
36
37
    /**
38
     * Render an exception into an HTTP response.
39
     *
40
     * @param  \Illuminate\Http\Request  $request
41
     * @param  \Exception  $exception
42
     * @return \Illuminate\Http\Response
43
     */
44
    public function render($request, Exception $exception)
45
    {
46
        return parent::render($request, $exception);
47
    }
48
49
    /**
50
     * Convert an authentication exception into an unauthenticated response.
51
     *
52
     * @param  \Illuminate\Http\Request  $request
53
     * @param  \Illuminate\Auth\AuthenticationException  $exception
54
     * @return \Illuminate\Http\Response
55
     */
56
    protected function unauthenticated($request, AuthenticationException $exception)
0 ignored issues
show
Unused Code introduced by
The parameter $exception is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
    {
58
        if ($request->expectsJson()) {
59
            return response()->json(['error' => 'Unauthenticated.'], 401);
60
        }
61
62
        return redirect()->guest('login');
63
    }
64
}
65