/** * Executes a filter on a value if there is one. * * @param mixed $value value to filter * @param function $filter filter to use to transform * @return mixed filtered value */ function _transform($value, $filter) { if ($filter instanceof T_Filter) { return $filter->transform($value); } elseif ($filter) { return call_user_func_array($filter, array($value)); } else { return $value; } }
/** * Add a {@link net.objecthunter.exp4j.function.Function} implementation available for use in the expression * @param function $function the custom {@link net.objecthunter.exp4j.function.Function} implementation that should be available for use in the expression. * @return self the ExpressionBuilder instance */ public function func($function) { $this->userFunctions[$function->getName()] = $function; return $this; }
/** * Invoke a closure with context(explicitly or implicitly) * if Preview::$config->use_implicit_context is set to true, * the closure will be bound to the context object. * Otherwise context will be passed to closure as an argument. * * @param function $fn * @param object context object (new stdClass) * @return mixed */ protected function invoke_closure_with_context($fn, $context) { if (Preview::$config->use_implicit_context) { return $fn->bindTo($context, $context)->__invoke(); } else { return $fn->__invoke($context); } }