Check if class matches the expected one.

@param object $object
@param array $expectedClasses

@throws \InvalidArgumentException
421965
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}.");
        }
    }
1278449
private function isValidQuickReplies(array $quickReplies): void
    {
        $this->isValidArray($quickReplies, 11, 1);
        foreach ($quickReplies as $quickReply) {
            if (!$quickReply instanceof QuickReply) {
                throw new InvalidClassException(sprintf(
                    'Array can only contain instance of %s.',
                    QuickReply::class
                ));
            }
        }
    }
297811
private function checkEntity( $obj )
    {
        if( $class = $this->classGet() and !( $obj instanceof $class ) ) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Obj %s is not compatible with Container of class %s',
                    get_class( $obj ),
                    $class
                )
            );
        }
        return true;
    }
982868
protected function assertValid(array $classes)
    {
        parent::assertValid($classes);

        foreach ($classes as $config) {
            if (!is_subclass_of($config, ConfigurationInterface::class)) {
                throw ConfigurationException::invalidClass($config);
            }
        }
    }
850916
public function equalsTo(Object $object)
    {
        if (!$this->sameTypeAs($object)) {
            throw new NotMatchTypeException($this);
        }

        return $this->start()->equalsTo($object->start()) && $this->duration()->equalsTo($object->duration()) && $this->recurrence() === $object->recurrence();
    }
834616
public function assertObjectInstance($object)
    {
        if (!$object instanceof $this->className) {
            if (is_object($object)) {
                $className = get_class($object);
            } else {
                $className = gettype($object);
            }
            throw new \InvalidArgumentException("Object must be an instance of {$this->className}, {$className} given");
        }
    }
309701
public static function isCompatible( $object, &$error = null )
    {

        if( !( $object instanceof Container ) ) {
            $error = 'Only Entity\\Containers are NormalityCollection compatible';
            return false;
        }

        // Pete. Humm. Not sure we even need this one. It probably is enough to be of the correct type.
        if( $firstElement = $object->firstElementGet() ) {
            return parent::isCompatible( $firstElement, $error );
        }

        return true;

    }
792026
public static function reset($object)
	{
		if (!($object instanceof FileDescriptorProto)) {
			throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileDescriptorProto.');
		}
		$object->name = NULL;
		$object->package = NULL;
		$object->dependency = NULL;
		$object->publicDependency = NULL;
		$object->weakDependency = NULL;
		$object->messageType = NULL;
		$object->enumType = NULL;
		$object->service = NULL;
		$object->extension = NULL;
		$object->options = NULL;
		$object->sourceCodeInfo = NULL;
		$object->syntax = NULL;
	}
1308215
public function validate ($object = null)
	{
		if (!isset ($this->context))
		{
			throw new InvalidParameter ("You must set a context before validating or filtering.");
		}

		$result = $this->reduce ($this->context, $object);

		if ($result)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
990485
public function class($subject, string $className) : bool
    {
        if (!$className) {
            throw new InvalidArgumentException('Arg className is empty.');
        }
        return $subject && is_object($subject) && is_a($subject, $className);
    }
106588
public function setParent($object) {
		
		if (! is_object($object)) {
			throw new \InvalidArgumentException("Expecting object, given: ".gettype($object));
		}
		
		$this->parent = $object;
		return $this;
	}
985165
protected function doesContainsObjects(array $objects) : bool
    {
        $objectsLookup = $this->asArray();

        foreach ($objects as $object) {
            if (!in_array($object, $objectsLookup, false)) {
                return false;
            }
        }

        return true;
    }
902053
public function setObject($object)
    {
        if (! is_object($object)) {
            throw new InvalidArgumentException(
                sprintf('The parameter given to setObject method of %s class is not an object', get_called_class())
            );
        }

        $this->object = $object;
        return $this;
    }
985376
public function addMethods($object, array $method_aliases = [])
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('$object must be an object');
        }
        foreach ($method_aliases as $alias => $method) {
            $callable = [$object, $method];
            if (!is_callable($callable)) {
                $class = get_class($object);
                throw new \InvalidArgumentException("Method {$method} not found in class {$class}");
            }
            if (is_int($alias)) {
                $alias = $method;
            }
            $this->plugins[$alias] = $callable;
        }
    }
546434
public function checkClasses($classes, array $options)
    {
        if (empty($options['class'])) {
            return false;
        }

        $options['class'] = $this->_toClassArray($options['class']);
        $classes = $this->_toClassArray($classes);

        foreach ($classes as $class) {
            if (!in_array($class, $options['class'])) {
                return false;
            }
        }

        return true;
    }
1000421
protected function _readHasErrors($object)
    {
        if ($object instanceof EntityInterface && $object->hasErrors()) {
            return true;
        }

        if (is_array($object)) {
            foreach ($object as $value) {
                if ($this->_readHasErrors($value)) {
                    return true;
                }
            }
        }

        return false;
    }
583069
private Class detectClass(final Object object) {
        if (object instanceof Class) {
            return (Class) object;
        }
        return object.getClass();
    }