Passed
Push — master ( 67284c...b0f0bc )
by ma
01:59
created

TException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 19
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A getHeaders() 0 3 1
1
<?php
2
namespace tinymeng\tools\exception;
3
4
use Exception;
5
6
/**
7
 * Class TException
8
 * @package tinymeng\tools\exception
9
 * @Author: TinyMeng <[email protected]>
10
 * @Created: 2020/8/17
11
 */
12
class TException extends \Exception
13
{
14
    /**
15
     * @var int
16
     */
17
    private $headers;
18
19
    public function __construct(int $statusCode, string $message = '', Exception $previous = null, array $headers = [], $code = 0)
20
    {
21
        $this->headers    = $headers;
0 ignored issues
show
Documentation Bug introduced by
It seems like $headers of type array is incompatible with the declared type integer of property $headers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
22
23
        /** message */
24
        if(empty($message)) $message = isset(StatusCode::$status_code[$statusCode]) ? StatusCode::$status_code[$statusCode] :StatusCode::$status_code[StatusCode::COMMON_UNKNOWN];
25
        parent::__construct('ERROR_TINYMENG_TOOL: '.$message, $code, $previous);
26
    }
27
28
    public function getHeaders()
29
    {
30
        return $this->headers;
31
    }
32
}
33