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
XmlImportAstMath.php
74 lines
| 1 | <?php |
| 2 | // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals |
| 3 | /** |
| 4 | * @author Olexandr Zanichkovsky <olexandr.zanichkovsky@zophiatech.com> |
| 5 | * @package AST |
| 6 | */ |
| 7 | |
| 8 | require_once dirname(__FILE__) . '/XmlImportAstExpression.php'; |
| 9 | |
| 10 | /** |
| 11 | * Represents a function |
| 12 | */ |
| 13 | class XmlImportAstMath extends XmlImportAstExpression |
| 14 | { |
| 15 | /** |
| 16 | * Function arguments |
| 17 | * |
| 18 | * @var array |
| 19 | */ |
| 20 | private $arguments = array(); |
| 21 | |
| 22 | /** |
| 23 | * Creates new instance |
| 24 | * |
| 25 | * @param string $name |
| 26 | */ |
| 27 | public function __construct($name) |
| 28 | { |
| 29 | $this->name = $name; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Adds argument to a function |
| 34 | * |
| 35 | * @param XmlImportAstExpression $argument |
| 36 | */ |
| 37 | public function addArgument(XmlImportAstExpression $argument) |
| 38 | { |
| 39 | $this->arguments[] = $argument; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Gets function arguments |
| 44 | * |
| 45 | * @return array |
| 46 | */ |
| 47 | public function getArguments() |
| 48 | { |
| 49 | return $this->arguments; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * String representation of a function |
| 54 | * |
| 55 | * @return string |
| 56 | */ |
| 57 | public function __toString() |
| 58 | { |
| 59 | $result = "--> begin " . get_class($this) . "\n"; |
| 60 | foreach ($this->getArguments() as $argument) |
| 61 | { |
| 62 | $array = explode("\n", $argument); |
| 63 | for ($i = 0; $i < count($array); $i++) |
| 64 | { |
| 65 | $array[$i] = ' ' . $array[$i]; |
| 66 | } |
| 67 | $result .= implode("\n", $array) . "\n"; |
| 68 | } |
| 69 | |
| 70 | $result .= "--> end " . get_class($this); |
| 71 | |
| 72 | return $result; |
| 73 | } |
| 74 | } |