public static function valueOf($value)
    {
        if ($value instanceof self)
        {
            return $value;
        }

        if (is_null($value))
        {
            return null;
        }

        $class = get_called_class();

        if (!is_string($value))
        {
            throw new \InvalidArgumentException("The given object is neither $class nor string.");
        }

        foreach (self::$values as $element)
        {
            if ($element->name() == $value)
            {
                return $element;
            }
        }

        throw new \InvalidArgumentException("The given string cannot be parsed as $class.");
    }