private function getBestDelimiter($pattern)
{
// try do find something that's not used
$delimiters = array();
foreach (self::$delimiters as $k => $d) {
if (false === strpos($pattern, $d)) {
return $d;
}
$delimiters[$d] = array(substr_count($pattern, $d), $k);
}
// return the least used delimiter, using the position in the list as a tie breaker
uasort($delimiters, function ($a, $b) {
if ($a[0] === $b[0]) {
return Utils::cmpInt($a, $b);
}
return $a[0] < $b[0] ? -1 : 1;
});
return key($delimiters);
}