private function checkVariableType($object, array $expectedClasses)
    {
        if (!is_object($object)) {
            $msg = 'Expected variable of type object, got ' . gettype($object) . ". (field isn't multiple)";
            throw new \InvalidArgumentException($msg);
        }

        $classes = class_parents($object);
        $classes[] = $class = get_class($object);
        if (empty(array_intersect($classes, $expectedClasses))) {
            throw new \InvalidArgumentException("Expected object of type {$expectedClasses[0]}, got {$class}.");
        }
    }
private function checkVariableType($object, array $expectedClasses)
    {
        if (!is_object($object)) {
            $msg = 'Expected variable of type object, got ' . gettype($object) . ". (field isn't multiple)";
            throw new \InvalidArgumentException($msg);
        }

        $classes = class_parents($object);
        $classes[] = $class = get_class($object);
        if (empty(array_intersect($classes, $expectedClasses))) {
            throw new \InvalidArgumentException("Expected object of type {$expectedClasses[0]}, got {$class}.");
        }
    }
private function checkVariableType ( $ object , array $ expectedClasses ) { if ( ! is_object ( $ object ) ) { $ msg = 'Expected variable of type object, got ' . gettype ( $ object ) . ". (field isn't multiple)" ; throw new \ InvalidArgumentException ( $ msg ) ; } $ classes = class_parents ( $ object ) ; $ classes [ ] = $ class = get_class ( $ object ) ; if ( empty ( array_intersect ( $ classes , $ expectedClasses ) ) ) { throw new \ InvalidArgumentException ( "Expected object of type {$expectedClasses[0]}, got {$class}." ) ; } }
Check if class matches the expected one.

@param object $object
@param array $expectedClasses

@throws \InvalidArgumentException
Check if class matches the expected one .