| @@ 92-104 (lines=13) @@ | ||
| 89 | * @param \Closure $callable |
|
| 90 | * @return \Sufir\Calc\Calc |
|
| 91 | */ |
|
| 92 | public function registerFunction($name, \Closure $callable) |
|
| 93 | { |
|
| 94 | $objReflector = new \ReflectionObject($callable); |
|
| 95 | $reflector = $objReflector->getMethod('__invoke'); |
|
| 96 | $parameters = $reflector->getParameters(); |
|
| 97 | ||
| 98 | $this->functions[$name] = array( |
|
| 99 | 'args' => count($parameters), |
|
| 100 | 'func' => $callable, |
|
| 101 | ); |
|
| 102 | ||
| 103 | return $this; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * |
|
| @@ 112-124 (lines=13) @@ | ||
| 109 | * @param \Closure $callable |
|
| 110 | * @return \Sufir\Calc\Calc |
|
| 111 | */ |
|
| 112 | public function registerVariable($name, $value) |
|
| 113 | { |
|
| 114 | $objReflector = new \ReflectionObject($callable); |
|
| 115 | $reflector = $objReflector->getMethod('__invoke'); |
|
| 116 | $parameters = $reflector->getParameters(); |
|
| 117 | ||
| 118 | $this->functions[$name] = array( |
|
| 119 | 'args' => count($parameters), |
|
| 120 | 'func' => $callable, |
|
| 121 | ); |
|
| 122 | ||
| 123 | return $this; |
|
| 124 | } |
|
| 125 | ||
| 126 | /** |
|
| 127 | * @param string $operator |
|