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