BetterReflection\Reflection\ReflectionClass::isInstance PHP Method

isInstance() public method

Checks whether the given object is an instance.
public isInstance ( object $object ) : boolean
$object object
return boolean
    public function isInstance($object)
    {
        if (!is_object($object)) {
            throw NotAnObject::fromNonObject($object);
        }
        $className = $this->getName();
        // note: since $object was loaded, we can safely assume that $className is available in the current
        //       php script execution context
        return $object instanceof $className;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function isInstance($object)
 {
     return $this->betterReflectionClass->isInstance($object);
 }