Passed
Push — master ( a16fba...b633a0 )
by Mario
02:18
created

validInternalServerErrorJsonResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace RafflesArgentina\ResourceController\Exceptions;
4
5
class ResourceControllerException extends \Exception
6
{
7
    /**
8
     * Report the exception.
9
     *
10
     * @return void
11
     */
12
    public function report()
13
    {
14
        //
15
    }
16
17
    /**
18
     * Render the exception into an HTTP response.
19
     *
20
     * @param \Illuminate\Http\Request $request The request object.
21
     *
22
     * @return mixed
23
     */
24
    public function render($request)
25
    {
26
        if ($request->wantsJson()) {
27
            return $this->validInternalServerErrorJsonResponse($this->message);
28
        } else {
29
            return redirect()->back()->with(['rafflesargentina.status.error' => $this->message]);
30
        }
31
    }
32
33
    /**
34
     * Return a valid 500 Internal Server Error json response.
35
     *
36
     * @param string $message The response message.
37
     *
38
     * @return \Illuminate\Http\JsonResponse
39
     */
40
    public function validInternalServerErrorJsonResponse($message = 'Error')
0 ignored issues
show
Unused Code introduced by
The parameter $message 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

40
    public function validInternalServerErrorJsonResponse(/** @scrutinizer ignore-unused */ $message = 'Error')

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...
41
    {
42
        return response()->json(
43
            [
44
                'exception' => class_basename($this),
45
                'file' => basename($this->getFile()),
46
                'line' => $this->getLine(),
47
                'message' => $this->getMessage(),
48
                'trace' => $this->getTrace(),
49
            ], 500, [], JSON_PRETTY_PRINT
50
        );
51
    }
52
}
53