src/Enum.php
final public static function byName($name)
    {
        $instances = &static::getInstances();

        if (!array_key_exists($name, $instances)) {
            $instances[$name] = new static($name);
        }

        return $instances[$name];
    }
final public static function byName($name)
    {
        $instances = &static::getInstances();

        if (!array_key_exists($name, $instances)) {
            $instances[$name] = new static($name);
        }

        return $instances[$name];
    }
final public static function byName ( $ name ) { $ instances = & static :: getInstances ( ) ; if ( ! array_key_exists ( $ name , $ instances ) ) { $ instances [ $ name ] = new static ( $ name ) ; } return $ instances [ $ name ] ; }
Attempts to instantiate an Enum from a label name.

For example:

```
Fruit::byName('APPLE'); // Fruit::APPLE()
Fruit::byName('BANANA'); // Fruit::BANANA()
Fruit::byName('UNKNOWN'); // exception
```

@param string $name

@return static

@throws Enum\Exception\InvalidInstance
Attempts to instantiate an Enum from a label name .