public function setEnvironment($environment)
{
if ($this->booting) {
throw new \RuntimeException('Cannot set environment after application has booted');
}
if ($environment instanceof Closure) {
$environment = call_user_func($environment);
}
if (!is_string($environment)) {
throw new \InvalidArgumentException('Environment must be a string');
}
$this->environment = $environment;
}