-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
200 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Services; | ||
|
||
use josegonzalez\Dotenv\Loader as DotEnv; | ||
|
||
/** | ||
* Class EnvService | ||
* @package App\Services | ||
*/ | ||
class EnvService | ||
{ | ||
|
||
public static $env = []; | ||
|
||
/** | ||
* Checks to see if there is a .env file in the directory. | ||
* | ||
* @return bool | ||
*/ | ||
public static function checkIfCanUseDotEnv(): bool | ||
{ | ||
$potentialPath = getcwd() . '/.env'; | ||
|
||
return file_exists($potentialPath); | ||
} | ||
|
||
/** | ||
* Load the environment variables. | ||
* | ||
* @return void | ||
*/ | ||
public static function loadDotEnv(): void | ||
{ | ||
static::$env = (new DotEnv(getcwd() . '/.env'))->parse()->toArray(); | ||
} | ||
|
||
/** | ||
* Return the environment variable by key. | ||
* | ||
* @param $key | ||
* @param null $default | ||
* @return string | ||
*/ | ||
public static function get($key, $default = null) | ||
{ | ||
return array_key_exists($key, static::$env) ? static::$env[$key] : $default; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.