<commit_before><?php

namespace PhpSchool\PhpWorkshop\Exception;

/**
 * Class InvalidArgumentException
 * @package PhpSchool\PhpWorkshop\Exception
 * @author <NAME> <<EMAIL>>
 */
class InvalidArgumentException extends \InvalidArgumentException
{
    /**
     * @param string $expected
     * @param mixed $actual
     * @return static
     */
    public static function typeMisMatch($expected, $actual)
    {
        return new static(
            sprintf(
                'Expected: "%s" Received: "%s"',
                $expected,
                is_object($actual) ? get_class($actual) : gettype($actual)
            )
        );
    }
}
<commit_msg>Add new static constructor for invalid parameters<commit_after><?php

namespace PhpSchool\PhpWorkshop\Exception;

/**
 * Class InvalidArgumentException
 * @package PhpSchool\PhpWorkshop\Exception
 * @author <NAME> <<EMAIL>>
 */
class InvalidArgumentException extends \InvalidArgumentException
{
    /**
     * @param string $expected
     * @param mixed $actual
     * @return static
     */
    public static function typeMisMatch($expected, $actual)
    {
        return new static(
            sprintf(
                'Expected: "%s" Received: "%s"',
                $expected,
                is_object($actual) ? get_class($actual) : gettype($actual)
            )
        );
    }

    /**
     * @param string $parameterName
     * @param mixed[] $allowedValues
     * @param mixed $actualValue
     * @return static
     */
    public static function notValidParameter($parameterName, array $allowedValues, $actualValue)
    {
        return new static(
            sprintf(
                'Parameter: "%s" can only be one of: "%s" Received: "%s"',
                $parameterName,
                static::stringify($allowedValues),
                static::stringify($actualValue)
            )
        );
    }

    /**
     * @param $value
     * @return string
     */
    public static function stringify($value)
    {
        if (is_object($value)) {
            return get_class($value);
        }

        if (is_array($value)) {
            return implode('", "', array_map([static::class, 'stringify'], $value));
        }

        if (is_scalar($value)) {
            return (string) $value;
        }

        if (is_bool($value)) {
            return ($value) ? 'true' : 'false';
        }

        return 'unknown';
    }
}

{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0, 'mean_word_length': 2.005006257822278, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '4031082', 'n_tokens_mistral': 670, 'n_tokens_neox': 648, 'n_words': 151}