HttpException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Exception;
6
7
use Psr\Log\LogLevel;
8
9
class HttpException extends ErrorException
10
{
11
    /**
12
     * @return int
13
     */
14
    protected $statusCode;
15
16
    /**
17
     * @return array
18
     */
19
    protected $headers;
20
21
    /**
22
     * @param string $message    Error message
23
     * @param int    $statusCode HTTP status code
24
     * @param int    $code       Internal code for the application error
25
     * @param string $logLevel   Log level of the error, from Psr\Log\LogLevel
26
     * @param array  $headers    Optional header response information
27
     */
28
    public function __construct(string $message, int $statusCode, int $code = 0, string $logLevel = LogLevel::WARNING, array $headers = [])
29
    {
30
        $this->statusCode = $statusCode;
31
        $this->headers = $headers;
32
33
        parent::__construct($message, $code, $logLevel);
34
    }
35
36
    public function getStatusCode(): int
37
    {
38
        return $this->statusCode;
39
    }
40
41
    public function getHeaders(): array
42
    {
43
        return $this->headers;
44
    }
45
}
46