Completed
Push — master ( e07632...dd03f2 )
by Alexander
09:25 queued 02:48
created

Handler::render()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 6
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 6
b 0
f 0
nc 3
nop 2
dl 0
loc 12
ccs 6
cts 6
cp 1
crap 3
rs 9.4285
1
<?php
2
3
namespace Flugg\Responder\Exceptions;
4
5
use Exception;
6
use Flugg\Responder\Exceptions\Http\HttpException;
7
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
9
/**
10
 * An exception handler responsible for handling exceptions.
11
 *
12
 * @package flugger/laravel-responder
13
 * @author  Alexander Tømmerås <[email protected]>
14
 * @license The MIT License
15
 */
16
class Handler extends ExceptionHandler
17
{
18
    use ConvertsExceptions;
19
20
    /**
21
     * Render an exception into an HTTP response.
22
     *
23
     * @param  \Illuminate\Http\Request $request
24
     * @param  \Exception               $exception
25
     * @return \Symfony\Component\HttpFoundation\Response
26
     */
27 7
    public function render($request, Exception $exception)
28
    {
29 7
        if ($request->wantsJson()) {
30 7
            $this->convertDefaultException($exception);
31
32 2
            if ($exception instanceof HttpException) {
33 1
                return $this->renderResponse($exception);
34
            }
35
        }
36
37 1
        return parent::render($request, $exception);
38
    }
39
}