<commit_before><?php
namespace PhpBrew;
use Exception;

class InvalidVariantSyntaxException extends Exception {}

class VariantParser
{

    public static function splitVariantValue($str)
    {
        if (strpos($str, '=') !== false) {
            list($name, $val) = explode('=', $str);

            return array($name => $val);
        }

        return array( $str => true );
    }

    public static function parseCommandArguments(array $args)
    {
        $extra = array();

        $enabledVariants = array();
        $disabledVariants = array();

        // split variant strings
        $startExtra = false;
        foreach ($args as $arg) {
            if ($arg === '--') {
                $startExtra = true;
                continue;
            }

            if ($startExtra) {
                $extra[] = $arg;
                continue;
            }

            if ($arg[0] === '+' || $arg[0] === '-') {
                if (substr($arg, 0, 2) === '--') {
                    throw new InvalidVariantSyntaxException($arg);
                }
                $variantStrings = preg_split('#(?=[+-])#', $arg);
                $variantStrings = array_filter($variantStrings);
                foreach ($variantStrings as $str) {
                    if ($str[0] == '+') {
                        $a = self::splitVariantValue(substr($str, 1));
                        $enabledVariants = array_merge($enabledVariants, $a);
                    } elseif ($str[0] == '-') {
                        $a = self::splitVariantValue(substr($str, 1));
                        $disabledVariants = array_merge($disabledVariants, $a);
                    } else {
                        throw new InvalidVariantSyntaxException($str);
                    }
                }
            } else {
                throw new InvalidVariantSyntaxException($arg);
            }
        }
        return array(
            'enabled_variants' => $enabledVariants,
            'disabled_variants' => $disabledVariants,
            'extra_options' => $extra,
        );
    }


    /**
     * Reveal the variants info to command arguments
     */
    public static function revealCommandArguments(array $info)
    {<commit_msg>Add more details to the exception message<commit_after><?php
namespace PhpBrew;
use Exception;

class InvalidVariantSyntaxException extends Exception {}

class VariantParser
{

    public static function splitVariantValue($str)
    {
        if (strpos($str, '=') !== false) {
            list($name, $val) = explode('=', $str);

            return array($name => $val);
        }

        return array( $str => true );
    }

    public static function parseCommandArguments(array $args)
    {
        $extra = array();

        $enabledVariants = array();
        $disabledVariants = array();

        // split variant strings
        $startExtra = false;
        foreach ($args as $arg) {
            if ($arg === '--') {
                $startExtra = true;
                continue;
            }

            if ($startExtra) {
                $extra[] = $arg;
                continue;
            }

            if ($arg[0] === '+' || $arg[0] === '-') {
                if (substr($arg, 0, 2) === '--') {
                    throw new InvalidVariantSyntaxException("Invalid variant syntax exception start with '--': " . $arg);
                }
                $variantStrings = preg_split('#(?=[+-])#', $arg);
                $variantStrings = array_filter($variantStrings);
                foreach ($variantStrings as $str) {
                    if ($str[0] == '+') {
                        $a = self::splitVariantValue(substr($str, 1));
                        $enabledVariants = array_merge($enabledVariants, $a);
                    } elseif ($str[0] == '-') {
                        $a = self::splitVariantValue(substr($str, 1));
                        $disabledVariants = array_merge($disabledVariants, $a);
                    } else {
                        throw new InvalidVariantSyntaxException($str . " is invalid syntax");
                    }
                }
            } else {
                throw new InvalidVariantSyntaxException("Unsupported variant syntax: $arg");
            }
        }
        return array(
            'enabled_variants' => $enabledVariants,
            'disabled_variants' => $disabledVariants,
            'extra_options' => $extra,
        );
    }


    /**
     * Reveal the variants info to command arguments
     */
    public static function revealCommandArguments(array $info)
    {
{'fraction_non_alphanumeric': 0.1323980710214818, 'fraction_numerical': 0.0035072336694432268, 'mean_word_length': 1.5126651982378854, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3803927', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1120, 'n_words': 262}