static function ByCreationMethod($name)
    {
        $enumClass = new \ReflectionClass(get_class());
        $calledClass = get_called_class();
        $reflectionClass = new \ReflectionClass($calledClass);
        $methods = $reflectionClass->getMethods(\ReflectionMethod::IS_STATIC);
        foreach ($methods as $method)
        {
            if ($method->name != $name)
                continue;
            
            if ($method->isPublic() && $method->getNumberOfParameters() == 0)
            {
                if (!$enumClass->hasMethod($method->name))
                {
                    $result = $method->invoke(null);
                    if (get_class($result) == $calledClass)
                        return $result;
                }
            }
        }
        throw new \InvalidArgumentException("'Creation method '$name' not found");
    }
static function ByCreationMethod($name)
    {
        $enumClass = new \ReflectionClass(get_class());
        $calledClass = get_called_class();
        $reflectionClass = new \ReflectionClass($calledClass);
        $methods = $reflectionClass->getMethods(\ReflectionMethod::IS_STATIC);
        foreach ($methods as $method)
        {
            if ($method->name != $name)
                continue;
            
            if ($method->isPublic() && $method->getNumberOfParameters() == 0)
            {
                if (!$enumClass->hasMethod($method->name))
                {
                    $result = $method->invoke(null);
                    if (get_class($result) == $calledClass)
                        return $result;
                }
            }
        }
        throw new \InvalidArgumentException("'Creation method '$name' not found");
    }
static function ByCreationMethod ( $ name ) { $ enumClass = new \ ReflectionClass ( get_class ( ) ) ; $ calledClass = get_called_class ( ) ; $ reflectionClass = new \ ReflectionClass ( $ calledClass ) ; $ methods = $ reflectionClass -> getMethods ( \ ReflectionMethod :: IS_STATIC ) ; foreach ( $ methods as $ method ) { if ( $ method -> name != $ name ) continue ; if ( $ method -> isPublic ( ) && $ method -> getNumberOfParameters ( ) == 0 ) { if ( ! $ enumClass -> hasMethod ( $ method -> name ) ) { $ result = $ method -> invoke ( null ) ; if ( get_class ( $ result ) == $ calledClass ) return $ result ; } } } throw new \ InvalidArgumentException ( "'Creation method '$name' not found" ) ; }
Searches the creation method with the given name and invokes it
@param string $name
@return Enum
@throws \InvalidArgumentException
Searches the creation method with the given name and invokes it