|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
7 |
* |
|
|
8 |
* For the full copyright and license information, please view the LICENSE |
|
|
9 |
* file that was distributed with this source code. |
|
|
10 |
*/ |
|
|
11 |
|
|
|
12 |
namespace Symfony\Component\CssSelector; |
|
|
13 |
|
|
|
14 |
/** |
|
|
15 |
* XPathExprOr represents XPath |'d expressions. |
|
|
16 |
* |
|
|
17 |
* Note that unfortunately it isn't the union, it's the sum, so duplicate elements will appear. |
|
|
18 |
* |
|
|
19 |
* This component is a port of the Python lxml library, |
|
|
20 |
* which is copyright Infrae and distributed under the BSD license. |
|
|
21 |
* |
|
|
22 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
23 |
*/ |
|
|
24 |
class XPathExprOr extends XPathExpr |
|
|
25 |
{ |
|
|
26 |
/** |
|
|
27 |
* Constructor. |
|
|
28 |
* |
|
|
29 |
* @param array $items The items in the expression. |
|
|
30 |
* @param string $prefix Optional prefix for the expression. |
|
|
31 |
*/ |
|
|
32 |
public function __construct($items, $prefix = null) |
|
|
33 |
{ |
|
|
34 |
$this->items = $items; |
|
|
35 |
$this->prefix = $prefix; |
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
/** |
|
|
39 |
* Gets a string representation of this |'d expression. |
|
|
40 |
* |
|
|
41 |
* @return string |
|
|
42 |
*/ |
|
|
43 |
public function __toString() |
|
|
44 |
{ |
|
|
45 |
$prefix = $this->prefix; |
|
|
46 |
|
|
|
47 |
$tmp = array(); |
|
|
48 |
foreach ($this->items as $i) { |
|
|
49 |
$tmp[] = sprintf('%s%s', $prefix, $i); |
|
|
50 |
} |
|
|
51 |
|
|
|
52 |
return implode($tmp, ' | '); |
|
|
53 |
} |
|
|
54 |
} |