Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 committed Mar 1, 2024
1 parent adca74b commit 080c4ee
Showing 1 changed file with 18 additions and 34 deletions.
52 changes: 18 additions & 34 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct()
{
$this->setApp();
$this->loadEnv();
$this->initializeEnvironment();
$this->configureEnvironment();
$this->registerProviders();
$this->bootServices();
}
Expand All @@ -62,42 +62,26 @@ private function loadEnv(): void
}

/**
* Initializes the application environment.
*
* This method sets up the application environment based on the value of
* APP_ENVIRONMENT. It configures error reporting and display settings
* according to the specified environment.
* @return void
*/
private function initializeEnvironment()
{
static $environment;
$environment ??= env('APP_ENVIRONMENT', 'production');

($environment === 'debug')
? self::configureForDebug()
: self::configureForProduction();
}

/**
* Configure error reporting and display settings for debugging.
* Configure error reporting and display settings based on the environment.
* @return void
*/
private static function configureForDebug()
private function configureEnvironment()
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
}

/**
* Configure error reporting and display settings for production.
* @return void
*/
private static function configureForProduction()
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED
& ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
ini_set('display_errors', 0);
static $initialized = false;
if (!$initialized) {
$environment = env('APP_ENVIRONMENT', 'production');

if ($environment === 'debug') {
ini_set('display_errors', 1);
error_reporting(E_ALL);
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED
& ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
ini_set('display_errors', 0);
}

$initialized = true;
}
}

/**
Expand Down

0 comments on commit 080c4ee

Please sign in to comment.