public static function compile($expression, $type = self::TYPE_CSS)
{
if (strcasecmp($type, self::TYPE_XPATH) === 0) {
return $expression;
}
$selectors = explode(',', $expression);
$paths = [];
foreach ($selectors as $selector) {
$selector = trim($selector);
if (array_key_exists($selector, static::$compiled)) {
$paths[] = static::$compiled[$selector];
continue;
}
static::$compiled[$selector] = static::cssToXpath($selector);
$paths[] = static::$compiled[$selector];
}
return implode('|', $paths);
}