BetterReflection\Reflection\ReflectionClass::isSubclassOf PHP Method

isSubclassOf() public method

Checks whether the given class string is a subclass of this class.
public isSubclassOf ( string $className ) : boolean
$className string
return boolean
    public function isSubclassOf($className)
    {
        if (!is_string($className)) {
            throw NotAString::fromNonString($className);
        }
        return in_array(ltrim($className, '\\'), array_map(function (self $reflectionClass) {
            return $reflectionClass->getName();
        }, array_slice(array_reverse($this->getInheritanceClassHierarchy()), 1)), true);
    }

Usage Example

 public function isSubclassOf(string $className) : bool
 {
     return $this->reflectionClass->isSubclassOf($className);
 }
All Usage Examples Of BetterReflection\Reflection\ReflectionClass::isSubclassOf