WordPress\AiClientDependencies\Http\Discovery

ClassDiscovery::instantiateClass │ protected static │ WP 1.0

Get an instance of the $class.

Метод класса: ClassDiscovery{}

Хуков нет.

Возвращает

object.

Использование

$result = ClassDiscovery::instantiateClass( $class );
$class(строка|\Closure) (обязательный)
a FQCN of a class or a closure that instantiate the class.

Код ClassDiscovery::instantiateClass() WP 7.1.2

protected static function instantiateClass($class)
{
    try {
        if (is_string($class)) {
            return new $class();
        }
        if (is_callable($class)) {
            return $class();
        }
    } catch (\Exception $e) {
        throw new ClassInstantiationFailedException('Unexpected exception when instantiating class.', 0, $e);
    }
    throw new ClassInstantiationFailedException('Could not instantiate class because parameter is neither a callable nor a string');
}