XmlImportAstElseif.php
14 years ago
XmlImportAstExpression.php
14 years ago
XmlImportAstFloat.php
14 years ago
XmlImportAstForeach.php
14 years ago
XmlImportAstFunction.php
14 years ago
XmlImportAstIf.php
14 years ago
XmlImportAstInteger.php
14 years ago
XmlImportAstLiteral.php
14 years ago
XmlImportAstMath.php
14 years ago
XmlImportAstPrint.php
14 years ago
XmlImportAstSequence.php
14 years ago
XmlImportAstStatement.php
14 years ago
XmlImportAstString.php
14 years ago
XmlImportAstText.php
14 years ago
XmlImportAstWith.php
14 years ago
XmlImportAstXPath.php
14 years ago
XmlImportAstXpathClause.php
14 years ago
XmlImportAstXpathClause.php
84 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com> |
| 4 | * @package AST |
| 5 | */ |
| 6 | |
| 7 | require_once dirname(__FILE__) . '/XmlImportAstStatement.php'; |
| 8 | require_once dirname(__FILE__) . '/XmlImportAstXPath.php'; |
| 9 | require_once dirname(__FILE__) . '/XmlImportAstSequence.php'; |
| 10 | |
| 11 | /** |
| 12 | * Represents a clause that is based on XPath |
| 13 | */ |
| 14 | abstract class XmlImportAstXPathClause extends XmlImportAstStatement |
| 15 | { |
| 16 | /** |
| 17 | * XPath expression |
| 18 | * |
| 19 | * @var XmlImportAstXPath |
| 20 | */ |
| 21 | private $xpath; |
| 22 | |
| 23 | /** |
| 24 | * Clause body |
| 25 | * |
| 26 | * @var XmlImportAstSequence |
| 27 | */ |
| 28 | private $body; |
| 29 | |
| 30 | /** |
| 31 | * Creates new instance |
| 32 | * |
| 33 | * @param XmlImportAstXPath $xpath |
| 34 | * @param XmlImportAstSequence $body |
| 35 | */ |
| 36 | public function __construct(XmlImportAstXPath $xpath, XmlImportAstSequence $body) |
| 37 | { |
| 38 | $this->xpath = $xpath; |
| 39 | $this->body = $body; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Gets XPath |
| 44 | * |
| 45 | * @return XmlImportAstXPath |
| 46 | */ |
| 47 | public function getXpath() |
| 48 | { |
| 49 | return $this->xpath; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Gets clause body |
| 54 | * |
| 55 | * @return XmlImportAstSequence |
| 56 | */ |
| 57 | public function getBody() |
| 58 | { |
| 59 | return $this->body; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * String representation of a clause |
| 64 | * |
| 65 | * @return string |
| 66 | */ |
| 67 | public function __toString() |
| 68 | { |
| 69 | $result = "--> begin " . get_class($this) . "\n"; |
| 70 | $result .= ' XPath: ' . $this->xpath . "\n"; |
| 71 | $result .= " Body:\n"; |
| 72 | |
| 73 | $array = explode("\n", $this->body); |
| 74 | for ($i = 0; $i < count($array); $i++) |
| 75 | { |
| 76 | $array[$i] = ' ' . $array[$i]; |
| 77 | } |
| 78 | |
| 79 | $result .= implode("\n", $array) . "\n"; |
| 80 | $result .= "--> end " . get_class($this) . "\n"; |
| 81 | return $result; |
| 82 | } |
| 83 | } |
| 84 |