Total Complexity | 3 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
9 | class InvalidElement extends \InvalidArgumentException |
||
10 | { |
||
11 | /** @var mixed */ |
||
12 | protected $var; |
||
13 | |||
14 | /** @var string */ |
||
15 | protected $needType; |
||
16 | |||
17 | public function __construct( |
||
18 | $var, |
||
19 | string $needType, |
||
20 | int $code = 0, |
||
21 | \Throwable $previous = null |
||
22 | ) { |
||
23 | $this->var = $var; |
||
24 | $this->needType = $needType; |
||
25 | |||
26 | $objectType = get_class($var); |
||
27 | |||
28 | parent::__construct( |
||
29 | "Element {$objectType} must be instance of " . $needType, |
||
30 | $code, |
||
31 | $previous |
||
32 | ); |
||
33 | } |
||
34 | |||
35 | public function getVar() |
||
36 | { |
||
37 | return $this->var; |
||
38 | } |
||
39 | |||
40 | public function getNeedType(): string |
||
43 | } |
||
44 | } |
||
45 |