Assert\Assertion::subclassOf PHP Метод

subclassOf() публичный статический Метод

Assert that value is subclass of given class-name.
public static subclassOf ( mixed $value, string $className, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$className string
$message string | null
$propertyPath string | null
Результат boolean
    public static function subclassOf($value, $className, $message = null, $propertyPath = null)
    {
        if (!is_subclass_of($value, $className)) {
            $message = sprintf($message ?: 'Class "%s" was expected to be subclass of "%s".', static::stringify($value), $className);
            throw static::createException($value, $message, static::INVALID_SUBCLASS_OF, $propertyPath, array('class' => $className));
        }
        return true;
    }

Usage Example

Пример #1
0
 public function testValidSubclassOf()
 {
     Assertion::subclassOf(new ChildStdClass(), 'stdClass');
 }
All Usage Examples Of Assert\Assertion::subclassOf