| 1 | <?php |
||
| 9 | class FunctionSet { |
||
| 10 | private $elementData; |
||
| 11 | private $functions = []; |
||
| 12 | private $element; |
||
| 13 | |||
| 14 | public function __construct(Hook\ElementData $elementData) { |
||
| 17 | |||
| 18 | public function __call($name, $args) { |
||
| 19 | if (isset($this->functions[$name])) { |
||
| 20 | return $this->functions[$name]->run($this->getArgs0($name, $args), $this->element); |
||
| 21 | } |
||
| 22 | |||
| 23 | return false; |
||
| 24 | } |
||
| 25 | |||
| 26 | private function getArgs0($name, $args) { |
||
| 27 | if (isset($this->functions[$name]) && !($this->functions[$name] instanceof TSSFunction\Data)) { |
||
| 28 | $tokens = $args[0]; |
||
| 29 | if ($tokens->count() == 0) return []; |
||
| 30 | $parser = new \Transphporm\Parser\Value($this); |
||
| 31 | return $parser->parseTokens($tokens, $this->elementData->getData($this->element)); |
||
| 32 | } |
||
| 33 | else { |
||
| 34 | return iterator_to_array($args[0]); |
||
| 35 | } |
||
| 36 | |||
| 37 | } |
||
| 38 | |||
| 39 | public function addFunction($name, \Transphporm\TSSFunction $function) { |
||
| 42 | |||
| 43 | public function hasFunction($name) { |
||
| 46 | |||
| 47 | public function setElement(\DomElement $element) { |
||
| 50 | |||
| 51 | } |
||
| 52 |