| @@ 42-63 (lines=22) @@ | ||
| 39 | $this->aliases[$alias] = $this->aliases[$class]; |
|
| 40 | } |
|
| 41 | ||
| 42 | public function getHandler($class) |
|
| 43 | { |
|
| 44 | if(array_key_exists($class, $this->handlers)) { |
|
| 45 | return $this->handlers[$class]; |
|
| 46 | } |
|
| 47 | ||
| 48 | $parents = array_intersect(array_keys($this->handlers), class_parents($class)); |
|
| 49 | if($parents) { |
|
| 50 | return $this->handlers[array_pop($parents)]; |
|
| 51 | } |
|
| 52 | ||
| 53 | $interfaces = array_intersect(array_keys($this->interfaces), array_values(class_implements($class))); |
|
| 54 | if($interfaces) { |
|
| 55 | if(count($interfaces) > 1) { |
|
| 56 | throw new HydratorConflictException(sprintf('Class %s implements interfaces with colliding handlers!', $class)); |
|
| 57 | } |
|
| 58 | ||
| 59 | return $this->interfaces[array_shift($interfaces)]; |
|
| 60 | } |
|
| 61 | ||
| 62 | return null; |
|
| 63 | } |
|
| 64 | ||
| 65 | public function hydrate($class, array $data) |
|
| 66 | { |
|
| @@ 43-64 (lines=22) @@ | ||
| 40 | $this->aliases[$alias] = $this->aliases[$class]; |
|
| 41 | } |
|
| 42 | ||
| 43 | public function getHandler($class) |
|
| 44 | { |
|
| 45 | if(isset($class, $this->handlers)) { |
|
| 46 | return $this->handlers[$class]; |
|
| 47 | } |
|
| 48 | ||
| 49 | $parents = array_intersect(array_keys($this->handlers), class_parents($class)); |
|
| 50 | if($parents) { |
|
| 51 | return $this->handlers[array_pop($parents)]; |
|
| 52 | } |
|
| 53 | ||
| 54 | $interfaces = array_intersect(array_keys($this->interfaces), array_values(class_implements($class))); |
|
| 55 | if($interfaces) { |
|
| 56 | if(\count($interfaces) > 1) { |
|
| 57 | throw new NormalizerConflictException(sprintf('Class %s implements interfaces with colliding handlers!', $class)); |
|
| 58 | } |
|
| 59 | ||
| 60 | return $this->interfaces[array_shift($interfaces)]; |
|
| 61 | } |
|
| 62 | ||
| 63 | return $this->default; |
|
| 64 | } |
|
| 65 | ||
| 66 | public function setDefault(callable $handler) |
|
| 67 | { |
|