HttpException::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 3
eloc 6
nc 3
nop 2
1
<?php
2
3
namespace Huntie\JsonApi\Exceptions;
4
5
use Huntie\JsonApi\Support\JsonApiErrors;
6
use Illuminate\Foundation\Application;
7
use Illuminate\Http\Response;
8
use Illuminate\Http\Exceptions\HttpResponseException;
9
10
class HttpException extends HttpResponseException
11
{
12
    use JsonApiErrors;
13
14
    /**
15
     * Create a new HttpException instance.
16
     *
17
     * @param string            $message  The message for this exception
18
     * @param Response|int|null $response The response object or HTTP status code send to the client
19
     */
20
    public function __construct($message, $response = null)
21
    {
22
        if (is_null($response)) {
23
            $response = $this->error(Response::HTTP_BAD_REQUEST, $message);
24
        } else if (is_int($response)) {
25
            $response = $this->error($response, $message);
26
        }
27
28
        parent::__construct($response);
29
    }
30
}
31