1 | <?php |
||
21 | class XPathConvertor |
||
22 | { |
||
23 | /** |
||
24 | * @var RecursiveParser |
||
25 | */ |
||
26 | protected $parser; |
||
27 | |||
28 | /** |
||
29 | * Constructor |
||
30 | */ |
||
31 | 65 | public function __construct(RecursiveParser $parser = null) |
|
35 | |||
36 | /** |
||
37 | * Convert an XPath expression (used in a condition) into PHP code |
||
38 | * |
||
39 | * This method is similar to convertXPath() but it selectively replaces some simple conditions |
||
40 | * with the corresponding DOM method for performance reasons |
||
41 | * |
||
42 | * @param string $expr XPath expression |
||
43 | * @return string PHP code |
||
44 | */ |
||
45 | 33 | public function convertCondition($expr) |
|
79 | |||
80 | /** |
||
81 | * Convert an XPath expression (used as value) into PHP code |
||
82 | * |
||
83 | * @param string $expr XPath expression |
||
84 | * @return string PHP code |
||
85 | */ |
||
86 | 32 | public function convertXPath($expr) |
|
106 | |||
107 | /** |
||
108 | * Export an XPath expression as PHP with special consideration for XPath variables |
||
109 | * |
||
110 | * Will return PHP source representing the XPath expression, with special consideration for XPath |
||
111 | * variables which are returned as a method call to XPath::export() |
||
112 | * |
||
113 | * @param string $expr XPath expression |
||
114 | * @return string PHP representation of the expression |
||
115 | */ |
||
116 | 5 | protected function exportXPath($expr) |
|
127 | |||
128 | /** |
||
129 | * Convert a "current()" XPath expression to its PHP source representation |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 1 | protected function exportXPathCurrent() |
|
137 | |||
138 | /** |
||
139 | * Convert a fragment of an XPath expression to its PHP source representation |
||
140 | * |
||
141 | * @param string $fragment |
||
142 | * @return string |
||
143 | */ |
||
144 | 5 | protected function exportXPathFragment($fragment) |
|
148 | |||
149 | /** |
||
150 | * Convert an XSLT parameter to its PHP source representation |
||
151 | * |
||
152 | * @param string $param Parameter, including the leading $ |
||
153 | * @return string |
||
154 | */ |
||
155 | 1 | protected function exportXPathParam($param) |
|
161 | |||
162 | /** |
||
163 | * Generate and return the a parser with the default set of matchers |
||
164 | * |
||
165 | * @return RecursiveParser |
||
166 | */ |
||
167 | 65 | protected function getDefaultParser() |
|
187 | |||
188 | /** |
||
189 | * Tokenize an XPath expression for use in PHP |
||
190 | * |
||
191 | * @param string $expr XPath expression |
||
192 | * @return array |
||
193 | */ |
||
194 | 5 | protected function tokenizeXPathForExport($expr) |
|
211 | } |