<commit_before><?php
/**
 * @package toolkit
 */
/**
 * General is a utility class that offers a number miscellaneous of
 * functions that are used throughout Symphony.
 */

class General
{
    /**
     * Convert any special characters into their entity equivalents. Since
     * Symphony 2.3, this function assumes UTF-8 and will not double
     * encode strings.
     *
     * @uses htmlspecialchars()
     * @param string $source
     *  a string to operate on.
     * @return string
     *  the encoded version of the string.
     */
    public static function sanitize($source)
    {
        $source = htmlspecialchars($source, ENT_COMPAT, 'UTF-8', false);

        return $source;
    }

    /**
     * Convert any special characters into their entity equivalents.
     * Contrary to `sanitize()`, this version does double encode existing entities.
     *
     * @since Symphony 2.7.5
     * @uses htmlspecialchars()
     * @param string $source
     *  a string to operate on.
     * @return string
     *  the fully encoded version of the string.
     */
    public static function sanitizeDouble($source)
    {
        $source = htmlspecialchars($value, ENT_COMPAT, 'UTF-8', true);

        return $source;
    }

    /**
     * Revert any html entities to their character equivalents.
     *
     * @param string $str
     *  a string to operate on
     * @return string
     *  the decoded version of the string
     */
    public static function reverse_sanitize($str)
    {
        return htmlspecialchars_decode($str, ENT_COMPAT);
    }

    /**
     * Validate a string against a set of regular expressions.
     *
     * @param array|string $string
     *  string to operate on
     * @param array|string $rule
     *  a single rule or array of rules
     * @return boolean
     *  false if any of the rules in $rule do not match any of the strings in
     *  `$string`, return true otherwise.
     */<commit_msg>Rename the undefined var (#2823)<commit_after><?php
/**
 * @package toolkit
 */
/**
 * General is a utility class that offers a number miscellaneous of
 * functions that are used throughout Symphony.
 */

class General
{
    /**
     * Convert any special characters into their entity equivalents. Since
     * Symphony 2.3, this function assumes UTF-8 and will not double
     * encode strings.
     *
     * @uses htmlspecialchars()
     * @param string $source
     *  a string to operate on.
     * @return string
     *  the encoded version of the string.
     */
    public static function sanitize($source)
    {
        $source = htmlspecialchars($source, ENT_COMPAT, 'UTF-8', false);

        return $source;
    }

    /**
     * Convert any special characters into their entity equivalents.
     * Contrary to `sanitize()`, this version does double encode existing entities.
     *
     * @since Symphony 2.7.5
     * @uses htmlspecialchars()
     * @param string $source
     *  a string to operate on.
     * @return string
     *  the fully encoded version of the string.
     */
    public static function sanitizeDouble($source)
    {
        $source = htmlspecialchars($source, ENT_COMPAT, 'UTF-8', true);

        return $source;
    }

    /**
     * Revert any html entities to their character equivalents.
     *
     * @param string $str
     *  a string to operate on
     * @return string
     *  the decoded version of the string
     */
    public static function reverse_sanitize($str)
    {
        return htmlspecialchars_decode($str, ENT_COMPAT);
    }

    /**
     * Validate a string against a set of regular expressions.
     *
     * @param array|string $string
     *  string to operate on
     * @param array|string $rule
     *  a single rule or array of rules
     * @return boolean
     *  false if any of the rules in $rule do not match any of the strings in
     *  `$string`, return true otherwise.
     */
{'fraction_non_alphanumeric': 0.08896338318720991, 'fraction_numerical': 0.005157297576070139, 'mean_word_length': 2.2956669498725573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1871037', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1057, 'n_words': 408}