Passed
Push — bugfix/manager-not-created-aft... ( fcd1af )
by Chris
10:00
created

AdminException::getStatusCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Exceptions;
4
5
use Exception;
6
use Illuminate\Support\Facades\Log;
7
8
class AdminException extends Exception
9
{
10
    /**
11
     * @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...
12
     */
13
    private $links;
14
15
    /**
16
     * Custom constructor to add additional elements to render view.
17
     *
18
     * @param string     $message  Custom error message.
19
     * @param integer    $code     HTTP code to return.
20
     * @param \Throwable $previous The last exception thrown.
21
     * @param string[]   $links    A collection of links to send to the view.
22
     *
23
     * @return void
24
     */
25
    public function __construct(string $message, int $code, ?\Throwable $previous = null, array $links = null)
26
    {
27
        $this->links = $links;
28
        parent::__construct($message, $code, $previous);
29
    }
30
31
    /**
32
     * Render the exception into an HTTP response.
33
     *
34
     * @param  \Illuminate\Http\Request $request Incoming request object.
35
     * @return \Illuminate\Http\Response|\Illuminate\Contracts\Routing\ResponseFactory
36
     */
37
    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

37
    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...
38
    {
39
        return response()->view(
40
            'errors/admin',
41
            [
42
                'exception' => $this,
43
                'error' => [
44
                    "title" => "Error"
45
                ],
46
                'links' => $this->links
47
            ],
48
            500
49
        );
50
    }
51
52
    /**
53
     * Override, custom exception doesn't return a status code.
54
     *
55
     * @return mixed
56
     */
57
    public function getStatusCode()
58
    {
59
        return 500;
60
    }
61
}
62