WordPress\AiClient\Common
AbstractEnum::getInstance
Gets or creates a singleton instance for the given value and name.
Method of the class: AbstractEnum{}
No Hooks.
Returns
static. The enum instance.
Usage
$result = AbstractEnum::getInstance( $value, $name ): self;
- $value(string) (required)
- The enum value.
- $name(string) (required)
- The constant name.
Changelog
| Since 0.1.0 | Introduced. |
AbstractEnum::getInstance() AbstractEnum::getInstance code WP 7.0
private static function getInstance(string $value, string $name): self
{
$className = static::class;
if (!isset(self::$instances[$className])) {
self::$instances[$className] = [];
}
if (!isset(self::$instances[$className][$name])) {
$instance = new $className($value, $name);
self::$instances[$className][$name] = $instance;
}
/** @var static */
return self::$instances[$className][$name];
}