Phan\Language\Element\Clazz::getHierarchyDepth PHP Method

getHierarchyDepth() public method

public getHierarchyDepth ( CodeBase $code_base ) : integer
$code_base Phan\CodeBase The entire code base from which we'll find ancestor details
return integer This class's depth in the class hierarchy
    public function getHierarchyDepth(CodeBase $code_base) : int
    {
        if (!$this->hasParentType()) {
            return 0;
        }
        if (!$code_base->hasClassWithFQSEN($this->getParentClassFQSEN())) {
            // Let this emit an issue elsewhere for the
            // parent not existing
            return 0;
        }
        // Get the parent class
        $parent = $this->getParentClass($code_base);
        // Prevent infinite loops
        if ($parent == $this) {
            return 0;
        }
        return 1 + $parent->getHierarchyDepth($code_base);
    }