Total Complexity | 3 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
10 | class GenericEntityHydrator implements HydratorInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var Orm |
||
14 | */ |
||
15 | protected $orm; |
||
16 | |||
17 | /** |
||
18 | * @var Mapper |
||
19 | */ |
||
20 | protected $mapper; |
||
21 | |||
22 | public function __construct(Orm $orm, Mapper $mapper) |
||
26 | } |
||
27 | |||
28 | public function hydrate($attributes = []) |
||
29 | { |
||
30 | $attributes = $this->orm |
||
31 | ->getCastingManager() |
||
32 | ->castArray($attributes, $this->mapper->getCasts()); |
||
33 | $attributes = Arr::renameKeys($attributes, $this->mapper->getColumnAttributeMap()); |
||
34 | $class = $this->mapper->getEntityClass() ?? GenericEntity::class; |
||
35 | |||
36 | return new $class($attributes, $this->orm->getCastingManager()); |
||
37 | } |
||
38 | |||
39 | public function extract(EntityInterface $entity) |
||
50 | } |
||
51 | } |
||
52 |