Passed
Push — dependabot/npm_and_yarn/docs/u... ( 28266c )
by
unknown
10:55 queued 02:13
created

Handler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 15
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
3
namespace A17\Twill\Exceptions;
4
5
use Illuminate\Auth\AuthenticationException;
6
use App\Exceptions\Handler as ExceptionHandler;
0 ignored issues
show
Bug introduced by
The type App\Exceptions\Handler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Support\Facades\Route;
8
use Illuminate\Validation\ValidationException;
9
10
class Handler extends ExceptionHandler
11
{
12
    /**
13
     * Convert an authentication exception into a response.
14
     *
15
     * @param  \Illuminate\Http\Request  $request
16
     * @param  \Illuminate\Auth\AuthenticationException  $exception
17
     * @return \Symfony\Component\HttpFoundation\Response
18
     */
19
    protected function unauthenticated($request, AuthenticationException $exception)
20
    {
21
        return $request->expectsJson()
22
            ? response()->json(['message' => $exception->getMessage()], 401)
23
            : redirect()->guest($exception->redirectTo() ?? route('admin.login', Route::current()->parameters()));
24
    }
25
26
    /**
27
     * Get the Twill error view used to render a specified HTTP status code.
28
     *
29
     * @param  integer $statusCode
30
     * @return string
31
     */
32
    protected function getTwillErrorView($statusCode, $frontend = false)
33
    {
34
        if ($frontend) {
35
            return config('twill.frontend.views_path') . ".errors.$statusCode";
36
        }
37
38
        return view()->exists("admin.errors.$statusCode") ? "admin.errors.$statusCode" : "twill::errors.$statusCode";
39
    }
40
41
    protected function invalidJson($request, ValidationException $exception)
42
    {
43
        return response()->json($exception->errors(), $exception->status);
44
    }
45
}
46