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

InvalidAttributeException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 1

1 Method

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