protected function getClassesHierarchy(\Exception $e)
    {
        $exceptionClass = get_class($e);
        $exceptionClassesHierarchy = array_values(class_parents($exceptionClass));
        array_unshift($exceptionClassesHierarchy, $exceptionClass);
        $exceptionClassesHierarchy = array_flip($exceptionClassesHierarchy);
        return $exceptionClassesHierarchy;
    }
protected function getClassesHierarchy(\Exception $e)
    {
        $exceptionClass = get_class($e);
        $exceptionClassesHierarchy = array_values(class_parents($exceptionClass));
        array_unshift($exceptionClassesHierarchy, $exceptionClass);
        $exceptionClassesHierarchy = array_flip($exceptionClassesHierarchy);
        return $exceptionClassesHierarchy;
    }
protected function getClassesHierarchy ( \ Exception $ e ) { $ exceptionClass = get_class ( $ e ) ; $ exceptionClassesHierarchy = array_values ( class_parents ( $ exceptionClass ) ) ; array_unshift ( $ exceptionClassesHierarchy , $ exceptionClass ) ; $ exceptionClassesHierarchy = array_flip ( $ exceptionClassesHierarchy ) ; return $ exceptionClassesHierarchy ; }
Function calculates exception classes hierarchy

Example:

Given hierarchy:
class B extends A {}
class A extends Exception {}
//B => A => Exception

$this->getClassesHierarchy(new B)

Result:
[
'B' => 0,
'A' => 1,
'Exception' => 2,
]


@param \Exception $e
@return array where key is class name and value is index in the hierarchy
Function calculates exception classes hierarchy