/** * Apply multiple functions to variable. * @param mixed $var * @param string $functions * @return mixed */ protected function batch($var, $functions) { foreach (explode('|', $functions) as $function) { if ($this->engine->doesFunctionExist($function)) { $var = call_user_func(array($this, $function), $var); } elseif (is_callable($function)) { $var = call_user_func($function, $var); } else { throw new LogicException('The batch function could not find the "' . $function . '" function.'); } } return $var; }