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