PluginProbe ʕ •ᴥ•ʔ
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More / 1.7.2.1
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More v1.7.2.1
1.10.1.1 1.10.1 1.10.0.5 trunk 1.1.4 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.6.1 1.1.7 1.1.7.1 1.1.7.2 1.1.8 1.1.8.1 1.1.8.2 1.1.8.3 1.1.8.4 1.10.0.1 1.10.0.2 1.10.0.3 1.10.0.4 1.2.0 1.2.0.1 1.2.1 1.2.2 1.2.2.1 1.2.2.2 1.2.3 1.2.3.1 1.2.3.2 1.2.4 1.2.4.1 1.2.5 1.2.5.1 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.9 1.3.0 1.3.1 1.3.1.1 1.3.1.2 1.3.2 1.3.3 1.3.5 1.3.6 1.3.6.1 1.3.6.2 1.3.7.2 1.3.7.3 1.3.7.4 1.3.8 1.3.9.1 1.4.0.1 1.4.1.1 1.4.2 1.4.2.1 1.4.2.2 1.4.3 1.4.4 1.4.4.1 1.4.5 1.4.5.1 1.4.5.2 1.4.5.3 1.4.6 1.4.7.1 1.4.7.2 1.4.8.1 1.4.9 1.5.0.1 1.5.0.3 1.5.0.4 1.5.1 1.5.1.1 1.5.1.3 1.5.2.1 1.5.2.2 1.5.2.3 1.5.3 1.5.3.1 1.5.4.1 1.5.4.2 1.5.5 1.5.5.1 1.5.6 1.5.6.2 1.5.7 1.5.8.2 1.5.9.1 1.5.9.4 1.5.9.5 1.6.0.1 1.6.0.2 1.6.1 1.6.2.2 1.6.2.3 1.6.3.1 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.7 1.6.7.1 1.6.7.2 1.6.7.3 1.6.8 1.6.8.1 1.6.9 1.7.0 1.7.1.1 1.7.1.2 1.7.2 1.7.2.1 1.7.3 1.7.4 1.7.4.1 1.7.4.2 1.7.5.1 1.7.5.2 1.7.5.3 1.7.5.5 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.7.9.1 1.8.0.1 1.8.0.2 1.8.1.1 1.8.1.2 1.8.1.3 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.3.1 1.8.4 1.8.4.1 1.8.5.2 1.8.5.3 1.8.5.4 1.8.6.2 1.8.6.3 1.8.6.4 1.8.7.2 1.8.8.2 1.8.8.3 1.8.9.1 1.8.9.2 1.8.9.4 1.8.9.5 1.8.9.6 1.9.0.1 1.9.0.2 1.9.0.3 1.9.0.4 1.9.1.1 1.9.1.2 1.9.1.3 1.9.1.4 1.9.1.5 1.9.1.6 1.9.2.1 1.9.2.2 1.9.2.3 1.9.3.1 1.9.3.2 1.9.4.1 1.9.4.2 1.9.5 1.9.5.1 1.9.5.2 1.9.6 1.9.6.1 1.9.6.2 1.9.7.1 1.9.7.2 1.9.7.3 1.9.8.1 1.9.8.2 1.9.8.4 1.9.8.7 1.9.9.2 1.9.9.3 1.9.9.4
wpforms-lite / vendor / symfony / css-selector / XPath / XPathExpr.php
wpforms-lite / vendor / symfony / css-selector / XPath Last commit date
Extension 4 years ago Translator.php 4 years ago TranslatorInterface.php 4 years ago XPathExpr.php 4 years ago
XPathExpr.php
132 lines
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\XPath;
13
14 /**
15 * XPath expression translator interface.
16 *
17 * This component is a port of the Python cssselect library,
18 * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
19 *
20 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
21 *
22 * @internal
23 */
24 class XPathExpr
25 {
26 private $path;
27 private $element;
28 private $condition;
29
30 /**
31 * @param string $path
32 * @param string $element
33 * @param string $condition
34 * @param bool $starPrefix
35 */
36 public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false)
37 {
38 $this->path = $path;
39 $this->element = $element;
40 $this->condition = $condition;
41
42 if ($starPrefix) {
43 $this->addStarPrefix();
44 }
45 }
46
47 /**
48 * @return string
49 */
50 public function getElement()
51 {
52 return $this->element;
53 }
54
55 /**
56 * @param $condition
57 *
58 * @return $this
59 */
60 public function addCondition($condition)
61 {
62 $this->condition = $this->condition ? sprintf('(%s) and (%s)', $this->condition, $condition) : $condition;
63
64 return $this;
65 }
66
67 /**
68 * @return string
69 */
70 public function getCondition()
71 {
72 return $this->condition;
73 }
74
75 /**
76 * @return $this
77 */
78 public function addNameTest()
79 {
80 if ('*' !== $this->element) {
81 $this->addCondition('name() = '.Translator::getXpathLiteral($this->element));
82 $this->element = '*';
83 }
84
85 return $this;
86 }
87
88 /**
89 * @return $this
90 */
91 public function addStarPrefix()
92 {
93 $this->path .= '*/';
94
95 return $this;
96 }
97
98 /**
99 * Joins another XPathExpr with a combiner.
100 *
101 * @param string $combiner
102 * @param XPathExpr $expr
103 *
104 * @return $this
105 */
106 public function join($combiner, self $expr)
107 {
108 $path = $this->__toString().$combiner;
109
110 if ('*/' !== $expr->path) {
111 $path .= $expr->path;
112 }
113
114 $this->path = $path;
115 $this->element = $expr->element;
116 $this->condition = $expr->condition;
117
118 return $this;
119 }
120
121 /**
122 * @return string
123 */
124 public function __toString()
125 {
126 $path = $this->path.$this->element;
127 $condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']';
128
129 return $path.$condition;
130 }
131 }
132