public function testInstanceTester() { $instance = new ClassInfo(); static::assertTrue(ClassInfo::assertInstance($instance)); static::assertTrue(ClassInfo::isInstance($instance)); static::assertFalse(ClassInfo::isInstance(__CLASS__)); $this->expectException('\\InvalidArgumentException'); ClassInfo::assertInstance(__CLASS__); }
/** * Try to determine the type of passed item and proxies the call to the respective specific this[*] methods. * * @param object|string $what A class name, object instance, interface name, or trait name * @param object|null $bind Alternate $this binding for internal resolver instance * * @throws RuntimeException If passed value is not an instance, class, interface or trait * * @return ClassInspector|ObjectInspector|InterfaceInspector|TraitInspector */ public static function using($what, $bind = null) { if (ClassInfo::isInstance($what)) { return self::useInstance($what, $bind); } if (ClassInfo::isClass($what)) { return self::useClass($what, $bind); } if (ClassInfo::isInterface($what)) { return self::useInterface($what, $bind); } if (ClassInfo::isTrait($what)) { return self::useTrait($what); } throw RuntimeException::create('Invalid inspector argument provided (got %s)', var_export($what, true)); }