Clean the Url code

@param  string $code  Url code
@return string
496583
public static function clearQueryArg($code)
  {
    if (StringTools::left($code, 1) == '/') {
      $code = StringTools::right($code, StringTools::len($code)-1);
    }
    if (StringTools::right($code, 1) == '/') {
      $code = StringTools::left($code, StringTools::len($code)-1);
    }

    return $code;
  }
903277
public function cleanLink($link)
	{
		$link = strtolower(preg_replace(
					array('#[\\s-]+#', '#[^A-Za-z0-9/ -]+#'),
					array('-', ''),
				    $this->cleanString(urldecode($link))
		));

		$link = preg_replace('/\/+/', '/', $link);
		$link = preg_replace('/-+/', '-', $link);
		
		return $link;
	}
1162996
protected function filtreCode($code)
    {
        if (is_numeric($code)) {
            $code = (int) $code;
        }
        if (!isset($this->reasonPhraseDefault[ $code ])) {
            throw new \InvalidArgumentException('Status code is invalid.');
        }

        return $code;
    }
1298053
protected function forceNamespace($code)
    {
        if (0 === preg_match('/\nnamespace/', $code)) {

            $use = array_filter(explode(PHP_EOL, $code), function($string) {
                return substr($string, 0, 5) === 'use \\';
            });

            $code = str_replace($use, '', $code);
            return "\nnamespace\n{\n" . $code . "\n}\n";
        }

        return $code;
    }
488302
public function filter($code)
    {
        if (strpos($code, '<html') === false)
        {
            return $this->minify($code);
        }

        $utf8 = (string) '<?xml encoding="UTF-8">';

        $dom = new \DOMDocument;

        @$dom->loadHTML((string) $utf8 . $code);

        $elements = $dom->getElementsByTagName('*');

        $this->remove($elements);

        $html = $this->minify($dom->saveHTML());

        return $this->restore((string) $html);
    }
483809
public function renderIndentation($code = null)
    {
        if ($this->debug && !empty($code)) {
            $indentation = str_repeat(' ', $this->indentationStep);
            $code = $indentation.str_replace("\n", "\n".$indentation, $code);
        }

        return (string) $code;
    }
1180929
public function extractTagAttributes($code)
    {
        $param = array();
        $regexes = array(
            '([a-zA-Z0-9_]+)=([^"\'\s>]+)',  // read the parameters : name=value
            '([a-zA-Z0-9_]+)=["]([^"]*)["]', // read the parameters : name="value"
            "([a-zA-Z0-9_]+)=[']([^']*)[']"  // read the parameters : name='value'
        );

        foreach ($regexes as $regex) {
            preg_match_all('/'.$regex.'/is', $code, $match);
            $amountMatch = count($match[0]);
            for ($k = 0; $k < $amountMatch; $k++) {
                $param[trim(strtolower($match[1][$k]))] = trim($match[2][$k]);
            }
        }

        return $param;
    }
44219
public static function isValidCode( $code ) {
		return
			strcspn( $code, ":/\\\000" ) === strlen( $code )
			&& !preg_match( Title::getTitleInvalidRegex(), $code );
	}
461810
public static function GetCodeName( $code ) : string
   {

      switch ( $code )
      {

         case \E_ERROR:
         case \E_USER_ERROR:
            return 'ERROR';

         case \E_WARNING:
         case \E_USER_WARNING:
            return 'WARNING';

         case \E_DEPRECATED:
         case \E_USER_DEPRECATED:
            return 'DEPRECATED';

         case \E_NOTICE:
         case \E_USER_NOTICE:
            return 'NOTICE';

         case \E_PARSE:
            return 'PARSE';
         case \E_RECOVERABLE_ERROR:
            return 'RECOVERABLE ERROR';

         case \E_STRICT:
            return 'STRICT';

         default:
            if ( \is_string( $code ) )
            {
               return $code;
            }
            return 'OTHER';

      }

   }
65946
public static function getMessageByCode($code)
    {
        return isset(self::$_httpCodes[$code]) ? self::$_httpCodes[$code] : null;
    }
108637
public function filter($code)
    {
        $elements = (array) $this->elements($code);

        foreach ((array) $elements as $element)
        {
            $original = (string) $element->nodeValue;

            $minified = $this->minify($original);

            $minified = preg_replace('/\s+/', ' ', $minified);

            $minified = $this->minify($minified);

            $code = str_replace($original, $minified, $code);
        }

        return $code;
    }
104082
protected function analyseStyle($code)
    {
        // clean the spaces
        $code = preg_replace('/[\s]+/', ' ', $code);

        // remove the comments
        $code = preg_replace('/\/\*.*?\*\//s', '', $code);

        // split each CSS code "selector { value }"
        preg_match_all('/([^{}]+){([^}]*)}/isU', $code, $match);

        // for each CSS code
        $amountMatch = count($match[0]);
        for ($k = 0; $k < $amountMatch; $k++) {

            // selectors
            $names = strtolower(trim($match[1][$k]));

            // css style
            $styles = trim($match[2][$k]);

            // explode each value
            $styles = explode(';', $styles);

            // parse each value
            $css = array();
            foreach ($styles as $style) {
                $tmp = explode(':', $style);
                if (count($tmp) > 1) {
                    $cod = $tmp[0];
                    unset($tmp[0]);
                    $tmp = implode(':', $tmp);
                    $css[trim(strtolower($cod))] = trim($tmp);
                }
            }

            // explode the names
            $names = explode(',', $names);

            // save the values for each names
            foreach ($names as $name) {
                // clean the name
                $name = trim($name);

                // if a selector with something like :hover => continue
                if (strpos($name, ':') !== false) {
                    continue;
                }

                // save the value
                if (!isset($this->css[$name])) {
                    $this->css[$name] = $css;
                } else {
                    $this->css[$name] = array_merge($this->css[$name], $css);
                }

            }
        }

        // get he list of the keys
        $this->cssKeys = array_flip(array_keys($this->css));
    }
1260840
public function cleanParameterUrls($urls)
    {
        if (!is_array($urls)) {
            $urls = array($urls);
        }

        $urls = array_filter($urls);
        $urls = array_map('urldecode', $urls);

        foreach ($urls as &$url) {
            $url = $this->removeTrailingSlash($url);
            $scheme = parse_url($url, PHP_URL_SCHEME);
            if (empty($scheme)
                && strpos($url, '://') === false
            ) {
                $url = 'http://' . $url;
            }
            $url = trim($url);
            $url = Common::sanitizeInputValue($url);
        }

        $urls = array_unique($urls);
        return $urls;
    }
287466
public static function getDescription($code)
    {
        if (array_key_exists($code, self::$codes_to_string_map)) {
            return self::$codes_to_string_map[$code];
        } else {
            return false;
        }
    }
1271407
public static function __(string $code) : string
    {
        $t = self::getInstance();
        if (!isset($t->translations[$code])) {
            return $code;
        }
        return $t->translations[$code];
    }
49853
public static function getText($code)
    {
        $code = (int) $code;

        if (!self::exists($code)) {
            throw new \DomainException('Http Code does not exist!');
        }

        return self::$httpCodes[$code];
	}
624610
public static function getTokensFromString($code) {
      try {
        $tokens = token_get_all($code, TOKEN_PARSE);
      } catch (\ParseError $e) {
        // with TOKEN_PARSE flag, the function throws on invalid code
        // let's just ignore the error and tokenize the code without the flag
        $tokens = token_get_all($code);
      }

      foreach ($tokens as $index => $tokenData) {

        if (!is_array($tokenData)) {
          $previousIndex = $index - 1;

          /** @var Token $previousToken */
          $previousToken = $tokens[$previousIndex];
          $line = $previousToken->getLine() + substr_count($previousToken->getValue(), "\n");
          $tokenData = [
            Token::INVALID_TYPE,
            $tokenData,
            $line,
          ];
        }

        $token = new Token($tokenData);
        $token->setIndex($index);
        $tokens[$index] = $token;

      }

      return $tokens;
    }