public function prepare($code, $skip_validation = false)
{
$this->prepare_time = microtime(true);
if ($this->allow_constants && !$this->isDefinedFunc('define') && ($this->hasWhitelistedFuncs() || !$this->hasBlacklistedFuncs())) {
$this->whitelistFunc('define');
//makes no sense to allow constants if you can't define them!
}
if (!$skip_validation) {
$this->validate($code);
}
static::$sandboxes[$this->name] = $this;
$this->generated_code = $this->prepareNamespaces() . $this->prepareAliases() . $this->prepareConsts() . "\r\n" . '$closure = function(){' . "\r\n" . $this->prepareVars() . $this->prepended_code . ($skip_validation ? $code : $this->prepared_code) . $this->appended_code . "\r\n" . '};' . "\r\n" . 'if(method_exists($closure, "bindTo")){ $closure = $closure->bindTo(null); }' . "\r\n" . 'return $closure();';
usleep(1);
//guarantee at least some time passes
$this->prepare_time = microtime(true) - $this->prepare_time;
return $this->generated_code;
}