WordPress\AiClient\Common

AbstractEnum::__callpublicWP 0.1.0

Handles dynamic method calls for enum checking.

Method of the class: AbstractEnum{}

No Hooks.

Returns

true|false. True if the enum value matches.

Usage

$AbstractEnum = new AbstractEnum();
$AbstractEnum->__call( $name, $arguments ): bool;
$name(string) (required)
The method name.
$arguments(array) (required)
The method arguments.

Changelog

Since 0.1.0 Introduced.

AbstractEnum::__call() code WP 7.0

final public function __call(string $name, array $arguments): bool
{
    // Handle is* methods
    if (str_starts_with($name, 'is')) {
        $constantName = self::camelCaseToConstant(substr($name, 2));
        $constants = static::getConstants();
        if (isset($constants[$constantName])) {
            return $this->value === $constants[$constantName];
        }
    }
    throw new BadMethodCallException(sprintf('Method %s::%s does not exist', static::class, $name));
}