Total Complexity | 5 |
Total Lines | 41 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | final class MappedHydrator implements Hydrator |
||
15 | { |
||
16 | /** @var Hydrator */ |
||
17 | private $hydrator; |
||
18 | /** @var Mapping[] */ |
||
19 | private $properties; |
||
20 | |||
21 | private function __construct( |
||
22 | Hydrator $hydrator, |
||
23 | Mapping ...$properties |
||
24 | ) { |
||
25 | $this->hydrator = $hydrator; |
||
26 | $this->properties = $properties; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Enables hydration mapping for a hydrator. |
||
31 | * |
||
32 | * @param Hydrator $hydrator The hydrator to decorate with mapping. |
||
33 | * @param Mapping ...$properties The mapping to apply to the input data. |
||
34 | * @return Hydrator A decorated hydrator that maps the data. |
||
35 | */ |
||
36 | public static function using( |
||
37 | Hydrator $hydrator, |
||
38 | Mapping ...$properties |
||
39 | ): Hydrator { |
||
40 | return new MappedHydrator($hydrator, ...$properties); |
||
41 | } |
||
42 | |||
43 | /** @inheritdoc */ |
||
44 | public function writeTo(object $target, array $input): void |
||
55 | } |
||
56 | } |
||
57 |