- is_subclass_of: documentation ( source)
<?php
interface UserProviderInterface
{
public function supportsClass($class);
}
final class UserProvider implements UserProviderInterface
{
public function supportsClass($class): bool
{
return $class === self::class || is_subclass_of($class, self::class);
}
}
echo (new UserProvider())->supportsClass('');