WordPress\AiClientDependencies\Http\Discovery

ClassDiscovery::safeClassExistspublic staticWP 1.0

We need a "safe" version of PHP's "class_exists" because Magento has a bug (or they call it a "feature"). Magento is throwing an exception if you do class_exists() on a class that ends with "Factory" and if that file does not exits.

This function catches all potential exceptions and makes sure to always return a boolean.

Method of the class: ClassDiscovery{}

No Hooks.

Returns

true|false.

Usage

$result = ClassDiscovery::safeClassExists( $class );
$class(string) (required)
.

ClassDiscovery::safeClassExists() code WP 7.0

public static function safeClassExists($class)
{
    try {
        return class_exists($class) || interface_exists($class);
    } catch (\Exception $e) {
        return \false;
    }
}