Rephine

EnumDynamicity

Adds dynamicity of case names to PHP Enumerations.

It provides a method to dynamically retrieve an Enumeration case by its name.

Table of Contents

Methods

try()  : self|null
Maps a string to an enum instance or NULL.

Methods

try()

Maps a string to an enum instance or NULL.

public static try(non-empty-string $name) : self|null

The try() method translates a string or int into the corresponding Enum case, if any. If there is no matching case defined, it will return NULL.

Parameters
$name : non-empty-string

The name to map to an enum case.

Return values
self|null

A case instance of this enum, or null if not found.


        
On this page

Search results