AbstractEnum::getInstance( string $value, string $name ): static

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Gets or creates a singleton instance for the given value and name.

Parameters

$valuestringrequired
The enum value.
$namestringrequired
The constant name.

Return

static The enum instance.

Source

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];
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.