MetaValueError   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

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