2020-04-21 11:53:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Helpers;
|
|
|
|
|
|
|
|
use Carbon\CarbonTimeZone;
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
use Engelsystem\Container\ServiceProvider;
|
|
|
|
|
|
|
|
class ConfigureEnvironmentServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
public function register()
|
|
|
|
{
|
|
|
|
/** @var Config $config */
|
|
|
|
$config = $this->app->get('config');
|
|
|
|
|
|
|
|
$timezone = new CarbonTimeZone($config->get('timezone'));
|
|
|
|
$this->setTimeZone($timezone);
|
2020-04-21 12:19:31 +02:00
|
|
|
|
|
|
|
$this->displayErrors(false);
|
|
|
|
if ($config->get('environment') == 'development') {
|
|
|
|
$this->displayErrors(true);
|
|
|
|
$this->errorReporting(E_ALL);
|
|
|
|
}
|
2020-04-21 11:53:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param CarbonTimeZone $timeZone
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
*/
|
|
|
|
protected function setTimeZone(CarbonTimeZone $timeZone)
|
|
|
|
{
|
|
|
|
ini_set('date.timezone', $timeZone);
|
|
|
|
date_default_timezone_set($timeZone);
|
|
|
|
}
|
2020-04-21 12:19:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $displayErrors
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
*/
|
|
|
|
protected function displayErrors(bool $displayErrors)
|
|
|
|
{
|
|
|
|
ini_set('display_errors', $displayErrors);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $errorReporting
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
*/
|
|
|
|
protected function errorReporting(int $errorReporting)
|
|
|
|
{
|
|
|
|
error_reporting($errorReporting);
|
|
|
|
}
|
2020-04-21 11:53:19 +02:00
|
|
|
}
|