AdminException::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 12
ccs 0
cts 5
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace App\Exceptions;
4
5
use Exception;
6
use Illuminate\Support\Facades\Lang;
7
use Illuminate\Support\Facades\Log;
8
9
class AdminException extends Exception
10
{
11
    /**
12
     * @var $links A collection of links to pass to the view.
0 ignored issues
show
Documentation Bug introduced by
The doc comment $links at position 0 could not be parsed: Unknown type name '$links' at position 0 in $links.
Loading history...
13
     */
14
    private $links;
15
16
    /**
17
     * Custom constructor to add additional elements to render view.
18
     *
19
     * @param string     $message  Custom error message.
20
     * @param integer    $code     HTTP code to return.
21
     * @param \Throwable $previous The last exception thrown.
22
     * @param string[]   $links    A collection of links to send to the view.
23
     *
24
     * @return void
25
     */
26
    public function __construct(string $message, int $code, ?\Throwable $previous = null, array $links = null)
27
    {
28
        $this->links = $links;
29
        parent::__construct($message, $code, $previous);
30
    }
31
32
    /**
33
     * Render the exception into an HTTP response.
34
     *
35
     * @param  \Illuminate\Http\Request $request Incoming request object.
36
     * @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
37
     */
38
    public function render(\Illuminate\Http\Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
    public function render(/** @scrutinizer ignore-unused */ \Illuminate\Http\Request $request)

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

Loading history...
39
    {
40
        return response()->view(
0 ignored issues
show
Bug introduced by
The function response was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        return /** @scrutinizer ignore-call */ response()->view(
Loading history...
41
            'errors/admin',
42
            [
43
                'exception' => $this,
44
                'error' => [
45
                    'title' => Lang::get('errors.title'),
46
                ],
47
                'links' => $this->links
48
            ],
49
            500
50
        );
51
    }
52
53
    /**
54
     * Override, custom exception doesn't return a status code.
55
     *
56
     * @return mixed
57
     */
58
    public function getStatusCode()
59
    {
60
        return 500;
61
    }
62
}
63