src/ORM/DataObjectSchema.php
protected function checkRelationClass($class, $component, $relationClass, $type)
    {
        if (!is_string($component) || is_numeric($component)) {
            throw new InvalidArgumentException(
                "{$class} has invalid {$type} relation name"
            );
        }
        if (!is_string($relationClass)) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} is not a class name"
            );
        }
        if (!class_exists($relationClass)) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} references class {$relationClass} which doesn't exist"
            );
        }
        // Support polymorphic has_one
        if ($type === 'has_one') {
            $valid = is_a($relationClass, DataObject::class, true);
        } else {
            $valid = is_subclass_of($relationClass, DataObject::class, true);
        }
        if (!$valid) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} references class {$relationClass} "
                . " which is not a subclass of " . DataObject::class
            );
        }
    }
protected function checkRelationClass($class, $component, $relationClass, $type)
    {
        if (!is_string($component) || is_numeric($component)) {
            throw new InvalidArgumentException(
                "{$class} has invalid {$type} relation name"
            );
        }
        if (!is_string($relationClass)) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} is not a class name"
            );
        }
        if (!class_exists($relationClass)) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} references class {$relationClass} which doesn't exist"
            );
        }
        // Support polymorphic has_one
        if ($type === 'has_one') {
            $valid = is_a($relationClass, DataObject::class, true);
        } else {
            $valid = is_subclass_of($relationClass, DataObject::class, true);
        }
        if (!$valid) {
            throw new InvalidArgumentException(
                "{$type} relation {$class}.{$component} references class {$relationClass} "
                . " which is not a subclass of " . DataObject::class
            );
        }
    }
protected function checkRelationClass ( $ class , $ component , $ relationClass , $ type ) { if ( ! is_string ( $ component ) || is_numeric ( $ component ) ) { throw new InvalidArgumentException ( "{$class} has invalid {$type} relation name" ) ; } if ( ! is_string ( $ relationClass ) ) { throw new InvalidArgumentException ( "{$type} relation {$class}.{$component} is not a class name" ) ; } if ( ! class_exists ( $ relationClass ) ) { throw new InvalidArgumentException ( "{$type} relation {$class}.{$component} references class {$relationClass} which doesn't exist" ) ; } // Support polymorphic has_one if ( $ type === 'has_one' ) { $ valid = is_a ( $ relationClass , DataObject :: class , true ) ; } else { $ valid = is_subclass_of ( $ relationClass , DataObject :: class , true ) ; } if ( ! $ valid ) { throw new InvalidArgumentException ( "{$type} relation {$class}.{$component} references class {$relationClass} " . " which is not a subclass of " . DataObject :: class ) ; } }
Validate a given class is valid for a relation

@param string $class Parent class
@param string $component Component name
@param string $relationClass Candidate class to check
@param string $type Relation type (e.g. has_one)
Validate a given class is valid for a relation