diff -r 000000000000 -r 7f95f8617b0b vendor/symfony/src/Symfony/Component/CssSelector/XPathExprOr.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/symfony/src/Symfony/Component/CssSelector/XPathExprOr.php Sat Sep 24 15:40:41 2011 +0200 @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector; + +/** + * XPathExprOr represents XPath |'d expressions. + * + * Note that unfortunately it isn't the union, it's the sum, so duplicate elements will appear. + * + * This component is a port of the Python lxml library, + * which is copyright Infrae and distributed under the BSD license. + * + * @author Fabien Potencier + */ +class XPathExprOr extends XPathExpr +{ + /** + * Constructor. + * + * @param array $items The items in the expression. + * @param string $prefix Optional prefix for the expression. + */ + public function __construct($items, $prefix = null) + { + $this->items = $items; + $this->prefix = $prefix; + } + + /** + * Gets a string representation of this |'d expression. + * + * @return string + */ + public function __toString() + { + $prefix = $this->prefix; + + $tmp = array(); + foreach ($this->items as $i) { + $tmp[] = sprintf('%s%s', $prefix, $i); + } + + return implode($tmp, ' | '); + } +}