/** * 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); } }