Total Complexity | 5 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | final class VariadicConstructor implements Hydrates |
||
15 | { |
||
16 | private $class; |
||
17 | |||
18 | private function __construct(string $forTheClass) |
||
19 | { |
||
20 | $this->class = $forTheClass; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Creates a new variadic constructor calling hydrator. |
||
25 | * |
||
26 | * @param string $class The class to hydrate. |
||
27 | * @return Hydrates The variadic construction calling hydrator. |
||
28 | */ |
||
29 | public static function forThe(string $class): Hydrates |
||
32 | } |
||
33 | |||
34 | /** @inheritdoc */ |
||
35 | public function fromArray(array $input) |
||
36 | { |
||
37 | $class = $this->class; |
||
38 | try { |
||
39 | return new $class(...$input); |
||
40 | } catch (Throwable $exception) { |
||
41 | throw HydrationFailed::encountered($exception, $class); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | /** @inheritdoc */ |
||
46 | public function classFor(array $input): string |
||
49 | } |
||
50 | } |
||
51 |