HttpException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getStatusCode() 0 4 1
A getHeaders() 0 4 1
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