BadUrlException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace App\Exceptions\Api;
4
5
use Exception;
6
use Illuminate\Support\Facades\Lang;
7
8
class BadUrlException extends Exception
9
{
10
    /**
11
     * Constructor function.
12
     *
13
     * @param string     $message  Custom error message.
14
     * @param integer    $code     HTTP code to return.
15
     * @param \Throwable $previous The last exception thrown.
16
     *
17
     * @return void
18
     */
19
    public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
20
    {
21
        $message = Lang::get('errors.bad_url');
22
        $code = 422; // Unprocessable entity.
23
        parent::__construct($message, $code, $previous);
24
    }
25
26
    /**
27
     * Render the exception into an HTTP response.
28
     *
29
     * @param  \Illuminate\Http\Request $request Incoming request object.
30
     * @return \Illuminate\Http\Response
31
     */
32
    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

32
    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...
33
    {
34
        return response()->json(
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

34
        return /** @scrutinizer ignore-call */ response()->json(
Loading history...
35
            [
36
                'message' => $this->getMessage()
37
            ],
38
            $this->getCode()
39
        );
40
    }
41
}
42