AbstractEnum::from( string $value ): static

In this article

Creates an enum instance from a value, throws exception if invalid.

Parameters

$valuestringrequired
The enum value.

Return

static The enum instance.

Source

final public static function from(string $value): self
{
    $instance = self::tryFrom($value);
    if ($instance === null) {
        throw new InvalidArgumentException(sprintf('%s is not a valid backing value for enum %s', $value, static::class));
    }
    return $instance;
}

Changelog

VersionDescription
0.1.0Introduced.

User Contributed Notes

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