HttpException::getHttpMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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