You are here

private static function ApacheMatcherDumper::escape in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php \Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper::escape()

Escapes a string.

Parameters

string $string The string to be escaped:

string $char The character to be escaped:

string $with The character to be used for escaping:

Return value

string The escaped string

2 calls to ApacheMatcherDumper::escape()
ApacheMatcherDumper::dump in vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php
Dumps a set of Apache mod_rewrite rules.
ApacheMatcherDumper::dumpRoute in vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php
Dumps a single route.

File

vendor/symfony/routing/Matcher/Dumper/ApacheMatcherDumper.php, line 233

Class

ApacheMatcherDumper
Dumps a set of Apache mod_rewrite rules.

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

private static function escape($string, $char, $with) {
  $escaped = false;
  $output = '';
  foreach (str_split($string) as $symbol) {
    if ($escaped) {
      $output .= $symbol;
      $escaped = false;
      continue;
    }
    if ($symbol === $char) {
      $output .= $with . $char;
      continue;
    }
    if ($symbol === $with) {
      $escaped = true;
    }
    $output .= $symbol;
  }
  return $output;
}