| Total Complexity | 6 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | class GenericEntityHydrator implements HydratorInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var CastingManager |
||
| 14 | */ |
||
| 15 | protected $castingManager; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var Mapper |
||
| 19 | */ |
||
| 20 | protected $mapper; |
||
| 21 | |||
| 22 | public function setMapper(Mapper $mapper) |
||
| 25 | } |
||
| 26 | |||
| 27 | public function setCastingManager(CastingManager $castingManager) |
||
| 28 | { |
||
| 29 | $this->castingManager = $castingManager; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function hydrate(array $attributes = []) |
||
| 33 | { |
||
| 34 | $attributes = $this->castingManager |
||
| 35 | ->castArray($attributes, $this->mapper->getCasts()); |
||
| 36 | $attributes = Arr::renameKeys($attributes, $this->mapper->getColumnAttributeMap()); |
||
| 37 | $class = $this->mapper->getEntityClass() ?? GenericEntity::class; |
||
| 38 | |||
| 39 | return new $class($attributes, $this->castingManager); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function extract(EntityInterface $entity) |
||
| 52 | } |
||
| 53 | |||
| 54 | public function get($entity, $attribute) |
||
| 57 | } |
||
| 58 | |||
| 59 | public function set($entity, $attribute, $value) |
||
| 64 |