Cleans up $text using given $method.

@param string $text
@param string $method

@return string
335323
protected function cleanupText($text, $method)
    {
        switch ($method) {
            case 'url_cleanup':
                $sep = $this->getWordSeparator();
                $sepQ = preg_quote($sep);
                $text = preg_replace(
                    array(
                        '#[^a-zA-Z0-9_!.-]+#',
                        '#^[.]+|[!.]+$#', // Remove dots at beginning/end
                        "#\.\.+#", // Remove double dots
                        "#[{$sepQ}]+#", // Turn multiple separators into one
                        "#^[{$sepQ}]+|[{$sepQ}]+$#", // Strip separator from beginning/end
                    ),
                    array(
                        $sep,
                        $sep,
                        $sep,
                        $sep,
                        '',
                    ),
                    $text
                );
                break;
            case 'url_cleanup_iri':
                // With IRI support we keep all characters except some reserved ones,
                // they are space, ampersand, semi-colon, forward slash, colon, equal sign, question mark,
                //          square brackets, parenthesis, plus.
                //
                // Note: Space is turned into a dash to make it easier for people to
                //       paste urls from the system and have the whole url recognized
                //       instead of being broken off
                $sep = $this->getWordSeparator();
                $sepQ = preg_quote($sep);
                $prepost = ' .' . $sepQ;
                if ($sep != '-') {
                    $prepost .= '-';
                }
                $text = preg_replace(
                    array(
                        "#[ \\\\%\#&;/:=?\[\]()+]+#",
                        '#^[.]+|[!.]+$#', // Remove dots at beginning/end
                        "#\.\.+#", // Remove double dots
                        "#[{$sepQ}]+#", // Turn multiple separators into one
                        "#^[{$prepost}]+|[{$prepost}]+$#",
                    ),
                    array(
                        $sep,
                        $sep,
                        $sep,
                        $sep,
                        '',
                    ),
                    $text
                );
                break;
            case 'url_cleanup_compat':
                // Old style of url alias with lowercase only and underscores for separators
                $text = strtolower($text);
                $text = preg_replace(
                    array(
                        '#[^a-z0-9]+#',
                        '#^_+|_+$#',
                    ),
                    array(
                        '_',
                        '',
                    ),
                    $text
                );
                break;
            default:
                // Nothing
        }

        return $text;
    }
1031067
private static function getCalledMethod($method)
    {
        if (strpos($method, '::') !== false) {
            $methodChunks = explode('::', $method);
            $method = $methodChunks[1];
        }

        return $method;
    }
483563
public function method(string $method, string ...$methods): self
    {
        array_unshift($methods, $method);

        return $this->setAllowedMethods($methods);
    }
278873
public function parser($text)
    {
        //Gets all current class methods, except for `parser()` and `remove()`
        $methods = array_diff(get_child_methods(get_class()), ['parser', 'remove']);

        //Calls dynamically each method
        foreach ($methods as $method) {
            $text = call_user_func([$this, $method], $text);
        }

        return $text;
    }
618511
protected function filterMethod($method)
    {
        if ($method === null) {
            return $method;
        }

        if (!is_string($method)) {
            throw new InvalidArgumentException(sprintf(
                'Unsupported HTTP method; must be a string, received %s',
                (is_object($method) ? get_class($method) : gettype($method))
            ));
        }

        $method = strtoupper($method);
        if (preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method) !== 1) {
            throw new InvalidMethodException($this, $method);
        }

        return $method;
    }
642862
protected function prepareText($text, $remove = null)
    {
        $result = strtoupper($this->removeAccents(trim(html_entity_decode($text))));
        if ($remove)
            $result = str_replace(str_split($remove), '', $result);
        return $result;
    }
298032
private function validateMethod($method)
    {
        $prefix = substr($method, 0, 3);

        if ($prefix === 'get' || $prefix === 'set' || $prefix === 'has') {
            return lcfirst(substr($method, 3));
        }

        $prefix = substr($prefix, 0, 2);

        if ($prefix === 'is') {
            return lcfirst(substr($method, 2));
        }
    }
763331
public static String clean(String text) {
        if (text == null)
            return "";

        text = text.trim();
        text = text.replace("\"", "\\\"");
        text = text.replace("\'", "\\\'");
        text = text.replace("\n", "");
        text = text.replace("\r", "");
        return text;
    }
1364187
public function excludedForMethod($method) : bool
    {
        if (empty($this->only) && empty($this->except)) {
            return false;
        }

        return (!empty($this->only) && !in_array($method, $this->only)) ||
            (!empty($this->except) && in_array($method, $this->except));
    }
1102049
protected function getMethodPartAndVerb($method)
    {
        preg_match($this->methodRule, $method, $matches);

        return empty($matches) ? false : array_slice($matches, 1);
    }
235162
public static String clean(EvaluationContext ctx, Object text) {
        return Conversions.toString(text, ctx).replaceAll("\\p{C}", "");
    }
363820
public static function normalizeMethodName(string $method): string
    {
        // Methods cant start with a number in PHP - move it after text
        $method = preg_replace('{^([0-9]*)(.*)}', '$2$1', $method);
        if (is_numeric($method)) {
            $method = 'call' . $method;
        }

        // Methods cant be named after reserved keywords.
        $method = self::normalizeReservedKeywords($method, 'Call');

        return lcfirst(self::camelCase($method, '{[^a-z0-9_]+}i'));
    }
912208
public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = array()) 
    {
    	if ($mode == \Zend_Cache::CLEANING_MODE_MATCHING_TAG) {
            if ($tags) {
                if (!method_exists($this->_handle, 'tag_delete')) {
                    \Zend_Cache::throwException('Method tag_delete() is not supported by the PHP memcached extension!');
                }
                foreach ($tags as $tag) {
                    $this->_handle->tag_delete($tag);
                }
            }
        } else {
            return parent::clean($mode, $tags); 
        }
    }
849809
private String cleanAndTrimString(String text, int maxTextLength) {
        if (StringUtils.isNotBlank(text)) {
            String cleaned = text.trim().replaceAll("[\\s]+", " ");
            return cleaned.length() <= maxTextLength
                    ? cleaned
                    : cleaned.substring(0, maxTextLength) + " ...";
        }
        return text;
    }
1292789
private static function cryptStandard(
        $hash,
        $crypt_text,
        $method = self::DEFAULT_CHIPPER
    ) {
        /**
         * ------------------------------------
         * Doing convert string
         * ------------------------------------
         */
        $crypt_text = self::rotate($crypt_text, (strlen($hash) % 13));
        $add = 0;
        $iv = self::safeBase64Decode(sha1($method . @time()));
        if (strlen($hash) < strlen($crypt_text)) {
            $crypt_text = substr_replace($crypt_text, $iv, strlen($hash), 0);
        } else {
            $crypt_text = $crypt_text . $iv;
        }
        $div = strlen($crypt_text) / strlen($hash);
        $new_pass = '';
        while ($add <= $div) {
            $new_pass .= $hash;
            $add++;
        }

        $pass_arr = str_split($new_pass);
        $str_arr  = str_split($crypt_text);
        $ascii = '';
        foreach ($str_arr as $key => $asc) {
            $pass_int = ord($pass_arr[$key]);
            $str_int = ord($asc);
            $int_add = $str_int + $pass_int;
            $ascii .= chr(($int_add+strlen($crypt_text)));
        }

        return [
            self::safeBase64Encode($ascii),
            $method, // for what?
            $iv
        ];
    }
1179186
static function CorrectSpaces($text)
    {
        $chars = '!,;.?:';
        $charArray = str_split($chars);
        foreach ($charArray as $char)
        {
            $text = Str::Replace($char, $char . ' ', $text);
        }
        return  self::RemoveMultipleSpaces($text);
    }
582474
protected static function removeUnusedPlaceholders($text)
    {
        $text = preg_replace(self::PLACEHOLDER_REGEX, '', $text);
        return preg_replace(self::COMMAND_REGEX, '', $text);
    }