| 1 | <?php |
||
| 20 | class ExceptionValueMap |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Map of values mapped to exception class |
||
| 24 | * key => exception class |
||
| 25 | * value => value associated with exception. |
||
| 26 | * |
||
| 27 | * @var array |
||
| 28 | */ |
||
| 29 | private $map; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param array $map |
||
| 33 | */ |
||
| 34 | 12 | public function __construct(array $map) |
|
| 35 | { |
||
| 36 | 12 | $this->map = $map; |
|
| 37 | 12 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * Resolves the value corresponding to an exception object. |
||
| 41 | * |
||
| 42 | * @param \Exception $exception |
||
| 43 | * |
||
| 44 | * @return mixed|false Value found or false is not found |
||
| 45 | */ |
||
| 46 | 9 | public function resolveException(\Exception $exception) |
|
| 47 | { |
||
| 48 | 9 | return $this->doResolveClass(get_class($exception)); |
|
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Resolves the value corresponding to an exception class. |
||
| 53 | * |
||
| 54 | * @param string $class |
||
| 55 | * |
||
| 56 | * @return mixed|false if not found |
||
| 57 | */ |
||
| 58 | 9 | private function doResolveClass($class) |
|
| 72 | } |
||
| 73 |