HttpException   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 34
ccs 0
cts 11
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHttpCode() 0 3 1
A getHttpMessage() 0 3 1
A getData() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Exception;
6
7
use Canvas\Http\Response;
8
9
class HttpException extends Exception
10
{
11
    protected $httpCode = Response::BAD_REQUEST;
12
    protected $httpMessage = 'Bad Request';
13
    protected $data;
14
15
    /**
16
     * Get the http status code of the exception.
17
     *
18
     * @return string
19
     */
20
    public function getHttpCode() : int
21
    {
22
        return $this->httpCode;
23
    }
24
25
    /**
26
     * Get the message string from the exception.
27
     *
28
     * @return string
29
     */
30
    public function getHttpMessage() : string
31
    {
32
        return $this->httpMessage;
33
    }
34
35
    /**
36
     * Get the message DATA from the exception.
37
     *
38
     * @return string|null
39
     */
40
    public function getData() : ?array
41
    {
42
        return is_array($this->data) ? $this->data : [$this->data];
0 ignored issues
show
Bug Best Practice introduced by
The expression return is_array($this->d...ta : array($this->data) returns the type array which is incompatible with the documented return type null|string.
Loading history...
43
    }
44
}
45