Merge remote branch 'everzet/crawler-privatisation-fixes'

* everzet/crawler-privatisation-fixes:
  [DomCrawler] moved private methods under public ones (readability)
This commit is contained in:
Fabien Potencier 2011-03-13 09:26:41 +01:00
commit 843c449c73

View File

@ -560,6 +560,32 @@ class Crawler extends \SplObjectStorage
return $form;
}
static public function xpathLiteral($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, ', '));
}
private function getNode($position)
{
foreach ($this as $i => $node) {
@ -596,30 +622,4 @@ class Crawler extends \SplObjectStorage
return $nodes;
}
static public function xpathLiteral($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, ', '));
}
}