Passed
Push — testing ( a7098f...bdd682 )
by Alex
04:35
created

HttpException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 16 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Huntie\JsonApi\Exceptions;
4
5
use Huntie\JsonApi\Support\JsonApiErrors;
6
use Illuminate\Foundation\Application;
7
use Illuminate\Http\Response;
8
9
class_alias(
10
    version_compare(Application::VERSION, '5.4.0', '>=') ?
11
        'Illuminate\Http\Exceptions\HttpResponseException' :
12
        'Illuminate\Http\Exception\HttpResponseException',
13
    __NAMESPACE__ . '\HttpResponseException'
14
);
15
16
class HttpException extends HttpResponseException
17
{
18
    use JsonApiErrors;
19
20
    /**
21
     * Create a new HttpException instance.
22
     *
23
     * @param string            $message  The message for this exception
24
     * @param Response|int|null $response The response object or HTTP status code send to the client
25
     */
26
    public function __construct($message, $response = null)
27
    {
28
        if (is_null($response)) {
29
            $response = $this->error(Response::HTTP_BAD_REQUEST, $message);
30
        } else if (is_int($response)) {
31
            $response = $this->error($response, $message);
32
        }
33
34
        parent::__construct($response);
35
    }
36
}
37