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
XmlImportAstElseif.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com> |
| 4 | * @package AST |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * Represents ELSEIF branch of IF clause |
| 9 | */ |
| 10 | class XmlImportAstElseif |
| 11 | { |
| 12 | /** |
| 13 | * ELSEIF branch condition |
| 14 | * |
| 15 | * @var XmlImportAstExpression |
| 16 | */ |
| 17 | private $condition; |
| 18 | |
| 19 | /** |
| 20 | * ELSEIF branch body |
| 21 | * |
| 22 | * @var XmlImportAstSequence |
| 23 | */ |
| 24 | private $body; |
| 25 | |
| 26 | /** |
| 27 | * Creates new instance |
| 28 | * |
| 29 | * @param XmlImportAstExpression $condition |
| 30 | * @param XmlImportAstSequence $body |
| 31 | */ |
| 32 | public function __construct(XmlImportAstExpression $condition, XmlImportAstSequence $body) |
| 33 | { |
| 34 | $this->condition = $condition; |
| 35 | $this->body = $body; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Gets ELSEIF branch condition |
| 40 | * |
| 41 | * @return XmlImportAstExpression |
| 42 | */ |
| 43 | public function getCondition() |
| 44 | { |
| 45 | return $this->condition; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Gets body |
| 50 | * |
| 51 | * @return XmlImportAstSequence |
| 52 | */ |
| 53 | public function getBody() |
| 54 | { |
| 55 | return $this->body; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * String representation of an object |
| 60 | * |
| 61 | * @return string |
| 62 | */ |
| 63 | public function __toString() |
| 64 | { |
| 65 | $result = " Elseif:\n"; |
| 66 | $result .= ' Condition: ' . $this->condition . "\n"; |
| 67 | $result .= " Body:\n"; |
| 68 | $array = explode("\n", $this->body); |
| 69 | for ($i = 0; $i < count($array); $i++) |
| 70 | { |
| 71 | $array[$i] = ' ' . $array[$i]; |
| 72 | } |
| 73 | $result .= implode("\n", $array) . "\n"; |
| 74 | return $result; |
| 75 | } |
| 76 | } |
| 77 |