Passed
Push — master ( 2dfc84...94e87c )
by Edward
05:17
created

InvalidAttributeException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\UniLex\AST\Exception;
6
7
use DomainException;
8
use Throwable;
9
10
use function gettype;
11
12
final class InvalidAttributeException extends DomainException implements ExceptionInterface
13
{
14
15
    private $name;
16
17
    private $value;
18
19
    private $expectedType;
20
21
    public function __construct(string $name, $value, string $expectedType, Throwable $previous = null)
22
    {
23
        $this->name = $name;
24
        $this->value = $value;
25
        $this->expectedType = $expectedType;
26
        $actualType = gettype($this->value);
27
        parent::__construct(
28
            "Node attribute '{$this->name}' has invalid type: {$actualType} instead of expected {$this->expectedType}",
29
            0,
30
            $previous
31
        );
32
    }
33
}
34