| @@ 36-41 (lines=6) @@ | ||
| 33 | */ |
|
| 34 | public function hydrate($entity, array $data) |
|
| 35 | { |
|
| 36 | if (is_string($entity) && class_exists($entity)) { |
|
| 37 | $entity = new $entity; |
|
| 38 | } |
|
| 39 | elseif (!is_object($entity)) { |
|
| 40 | throw new Exception('Entity passed to ArrayHydrator::hydrate() must be a class name or entity object'); |
|
| 41 | } |
|
| 42 | ||
| 43 | $entity = $this->hydrateProperties($entity, $data); |
|
| 44 | $entity = $this->hydrateAssociations($entity, $data); |
|
| @@ 18-24 (lines=7) @@ | ||
| 15 | */ |
|
| 16 | public function hydrate($entity, array $data) |
|
| 17 | { |
|
| 18 | if (is_string($entity) && class_exists($entity)) { |
|
| 19 | $entity = new $entity; |
|
| 20 | } elseif (!is_object($entity)) { |
|
| 21 | throw new \InvalidArgumentException( |
|
| 22 | 'Entity passed to JsonApiHydrator::hydrate() must be a class name or entity object' |
|
| 23 | ); |
|
| 24 | } |
|
| 25 | ||
| 26 | if (isset($data['attributes']) && is_array($data['attributes'])) { |
|
| 27 | $entity = $this->hydrateProperties($entity, $data['attributes']); |
|