public function includePath($path, \closure $closure = null)
{
$this->resetErrors();
$this->path = (string) $path;
$errorHandler = $this->adapter->set_error_handler(array($this, 'errorHandler'));
$closure = $closure ?: function ($path) {
include_once $path;
};
$closure($this->path);
$this->adapter->restore_error_handler();
if (sizeof($this->errors) > 0) {
$realpath = parse_url($this->path, PHP_URL_SCHEME) !== null ? $this->path : realpath($this->path) ?: $this->path;
if (in_array($realpath, $this->adapter->get_included_files(), true) === false) {
throw new includer\exception('Unable to include \'' . $this->path . '\'');
}
if ($errorHandler !== null) {
foreach ($this->errors as $error) {
call_user_func_array($errorHandler, $error);
}
$this->errors = array();
}
}
return $this;
}