class Escaper
Same name in this branch
- 11.1.x vendor/symfony/yaml/Escaper.php \Symfony\Component\Yaml\Escaper
XPath escaper.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Behat\Mink\Selector\Xpath\Escaper
Expanded class hierarchy of Escaper
3 files declare their use of Escaper
- NamedSelector.php in vendor/
behat/ mink/ src/ Selector/ NamedSelector.php - SelectorsHandler.php in vendor/
behat/ mink/ src/ Selector/ SelectorsHandler.php - Selenium2Driver.php in vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php
File
-
vendor/
behat/ mink/ src/ Selector/ Xpath/ Escaper.php, line 18
Namespace
Behat\Mink\Selector\XpathView source
class Escaper {
/**
* Escapes the string as a XPath literal.
*
* @param string $s
*
* @return string
*/
public function escapeLiteral(string $s) {
if (false === strpos($s, "'")) {
return sprintf("'%s'", $s);
}
if (false === strpos($s, '"')) {
return sprintf('"%s"', $s);
}
$string = $s;
$parts = array();
while (true) {
if (false !== ($pos = strpos($string, "'"))) {
$parts[] = sprintf("'%s'", substr($string, 0, $pos));
$parts[] = "\"'\"";
$string = substr($string, $pos + 1);
}
else {
$parts[] = "'{$string}'";
break;
}
}
return sprintf('concat(%s)', implode(',', $parts));
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
Escaper::escapeLiteral | public | function | Escapes the string as a XPath literal. |