Total Complexity | 3 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class DecodedValue |
||
12 | { |
||
13 | /** |
||
14 | * Instantiate the class. |
||
15 | * |
||
16 | * @param mixed $value |
||
17 | */ |
||
18 | 92 | private function __construct( |
|
19 | public bool $succeeded, |
||
20 | public mixed $value = null, |
||
21 | public ?string $error = null, |
||
22 | public ?int $code = null, |
||
23 | public ?Throwable $exception = null, |
||
24 | public ?string $json = null, |
||
25 | ) { |
||
26 | 92 | } |
|
27 | |||
28 | /** |
||
29 | * Retrieve a successfully decoded value |
||
30 | * |
||
31 | * @param mixed $value |
||
32 | * @return static |
||
33 | */ |
||
34 | 90 | public static function succeeded(mixed $value): static |
|
37 | } |
||
38 | |||
39 | /** |
||
40 | * Retrieve a value failed to be decoded |
||
41 | * |
||
42 | * @param Throwable $e |
||
43 | * @param string $json |
||
44 | * @return static |
||
45 | */ |
||
46 | 6 | public static function failed(Throwable $e, string $json): static |
|
51 |