InvalidAttributeException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 18
rs 10
c 1
b 0
f 0
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
    private $name;
15
16
    private $value;
17
18
    private $expectedType;
19
20
    public function __construct(string $name, $value, string $expectedType, Throwable $previous = null)
21
    {
22
        $this->name = $name;
23
        $this->value = $value;
24
        $this->expectedType = $expectedType;
25
        $actualType = gettype($this->value);
26
        parent::__construct(
27
            "Node attribute '{$this->name}' has invalid type: {$actualType} instead of expected {$this->expectedType}",
28
            0,
29
            $previous
30
        );
31
    }
32
}
33