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