Total Complexity | 6 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class MutableCollectionHydrator implements Hydrator |
||
16 | { |
||
17 | private function __construct() |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Produces a collection hydrator. |
||
23 | * |
||
24 | * @return Hydrator A hydrator that calls the constructor through reflection. |
||
25 | */ |
||
26 | public static function default(): Hydrator |
||
27 | { |
||
28 | return new self(); |
||
29 | } |
||
30 | |||
31 | /** @inheritdoc */ |
||
32 | public function writeTo(object $collection, array $input): void |
||
33 | { |
||
34 | try { |
||
35 | assert($collection instanceof ArrayAccess); |
||
36 | $this->write($collection, $input); |
||
37 | } catch (Throwable $exception) { |
||
38 | throw HydrationFailed::encountered($exception, $collection); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | private function write(ArrayAccess $collection, array $input): void |
||
46 | } |
||
47 | } |
||
48 | } |
||
49 |