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