Handler::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Exceptions;
13
14
use Exception;
15
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
16
17
/**
18
 * Handler is a class to handler all of the application exceptions (reporting and rendering).
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 */
22
class Handler extends ExceptionHandler
23
{
24
    /**
25
     * A list of the exception types that should not be reported.
26
     *
27
     * @var array
28
     */
29
    protected $dontReport = [
30
        'Symfony\Component\HttpKernel\Exception\HttpException',
31
    ];
32
33
    /**
34
     * Report or log an exception.
35
     *
36
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
37
     *
38
     * @param \Exception $e
39
     *
40
     * @return void
41
     */
42 15
    public function report(Exception $e)
43
    {
44 15
        return parent::report($e);
45
    }
46
47
    /**
48
     * Render an exception into an HTTP response.
49
     *
50
     * @param \Illuminate\Http\Request $request
51
     * @param \Exception               $e
52
     *
53
     * @return \Illuminate\Http\Response
54
     */
55 15
    public function render($request, Exception $e)
56
    {
57 15
        if ($this->isHttpException($e)) {
58 14
            return $this->renderHttpException($e);
0 ignored issues
show
Compatibility introduced by
$e of type object<Exception> is not a sub-type of object<Symfony\Component...xception\HttpException>. It seems like you assume a child class of the class Exception to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
59
        } else {
60 1
            return parent::render($request, $e);
61
        }
62
    }
63
}
64