Symfony\Component\DependencyInjection\InterfaceInjector::supports PHP Method

supports() public method

Inspects if current interface injector is to be used with a given class
public supports ( string $object ) : boolean
$object string
return boolean
    public function supports($object)
    {
        if (is_string($object)) {
            $class = new \ReflectionClass($object);
            $object = $class->newInstance();
        }

        if ( ! is_object($object)) {
            throw new InvalidArgumentException(sprintf("%s expects class or object, %s given", __METHOD__, substr(str_replace("\n", '', var_export($object, true)), 0, 10)));
        }

        return is_a($object, $this->class);
    }

Usage Example

 /**
  * @expectedException Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
  */
 public function testSupportsThrowsExceptionOnInvalidArgument()
 {
     $injector = new InterfaceInjector('Symfony\\Tests\\Component\\DependencyInjection\\Service');
     $injector->supports(array());
 }