public static function toValue($constant)
    {
        if (false !== ($_index = array_search($constant, static::getDefinedConstants(true)))) {
            return $_index;
        }

        throw new \InvalidArgumentException('The constant "' . $constant . '" has no associated value.');
    }