Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Test Failed
Push — development ( 3add70...a51bef )
by José
06:20
created

Handler::render()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 28
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 28
rs 8.8571
cc 3
eloc 14
nc 3
nop 2
1
<?php
2
3
namespace DoeSangue\Exceptions;
4
5
use Exception;
6
use Illuminate\Auth\AuthenticationException;
7
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
8
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
9
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
10
11
class Handler extends ExceptionHandler
12
{
13
    /**
14
     * A list of the exception types that should not be reported.
15
     *
16
     * @var array
17
     */
18
    protected $dontReport = [
19
        \Illuminate\Auth\AuthenticationException::class,
20
        \Illuminate\Auth\Access\AuthorizationException::class,
21
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
22
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
23
        \Illuminate\Session\TokenMismatchException::class,
24
        \Illuminate\Validation\ValidationException::class,
25
    ];
26
27
    /**
28
     * Report or log an exception.
29
     *
30
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
31
     *
32
     * @param \Exception $exception
33
     */
34
    public function report(Exception $exception)
35
    {
36
        parent::report($exception);
37
    }
38
39
    /**
40
     * Render an exception into an HTTP response.
41
     *
42
     * @param \Illuminate\Http\Request $request
43
     * @param \Exception               $exception
44
     *
45
     * @return \Illuminate\Http\Response
46
     */
47
    public function render($request, Exception $exception)
48
    {
49
        // Validate 404 exceptions.
50
        if($exception instanceof NotFoundHttpException) {
51
            return response()->json(
52
                [
53
                'error' => [
54
                    'description' => 'Invalid URI',
55
                    'messages' => []
56
                ]
57
                ], 404
58
            );
59
        }
60
61
        // Method not allowed exception handler
62
        if($exception instanceof MethodNotAllowedHttpException) {
63
            return response()->json(
64
                [
65
                'error' => [
66
                    'description' => 'Method Not Allowed',
67
                    'messages' => []
68
                ]
69
                ], 405
70
            );
71
        }
72
73
        return parent::render($request, $exception);
74
    }
75
76
    /**
77
     * Convert an authentication exception into an unauthenticated response.
78
     *
79
     * @param \Illuminate\Http\Request                 $request
80
     * @param \Illuminate\Auth\AuthenticationException $exception
81
     *
82
     * @return \Illuminate\Http\Response
83
     */
84
    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...
85
    {
86
        if ($request->expectsJson()) {
87
            return response()->json(['error' => 'Unauthenticated.'], 401);
88
        }
89
90
        return redirect()->guest('login');
91
    }
92
93
94
}
95