MetaValueError::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 0
loc 10
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace BiiiiiigMonster\LaravelEnum\Exceptions;
4
5
use BiiiiiigMonster\LaravelEnum\Concerns\Meta;
6
use ValueError;
7
8
class MetaValueError extends ValueError
9
{
10
    public function __construct(string $enum, mixed $value, string $method = null)
11
    {
12
        if ($value instanceof Meta) {
13
            $method = $value::class;
14
            $value = $value->value;
15
        }
16
17
        // Matches the error message of invalid Foo::BAR access
18
        parent::__construct('Enum '.$enum.' does not have a case with a meta property "'.
19
            $method.'" of value "'.$value.'"');
20
    }
21
}
22