Passed
Branch related-record-fixes (1a5bc9)
by Alex
02:41
created

HttpException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
1
<?php
2
3
namespace Huntie\JsonApi\Exceptions;
4
5
use Huntie\JsonApi\Support\JsonApiErrors;
6
use Illuminate\Http\Response;
7
use Illuminate\Http\Exception\HttpResponseException;
8
9
class HttpException extends HttpResponseException
10
{
11
    use JsonApiErrors;
12
13
    /**
14
     * Create a new HttpException instance.
15
     *
16
     * @param string            $message  The message for this exception
17
     * @param Response|int|null $response The response object or HTTP status code send to the client
18
     */
19
    public function __construct($message, $response = null)
20
    {
21
        if (is_null($response)) {
22
            $response = $this->error(Response::HTTP_BAD_REQUEST, $message);
23
        } else if (is_int($response)) {
24
            $response = $this->error($response, $message);
25
        }
26
27
        parent::__construct($response);
28
    }
29
}
30