2021-10-23 14:11:19 +03:00
|
|
|
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------------
|
2024-01-01 01:14:38 +03:00
|
|
|
|
* MaketRandevu - MAKET Randevu Portalı
|
2021-10-23 14:11:19 +03:00
|
|
|
|
*
|
|
|
|
|
* @package EasyAppointments
|
|
|
|
|
* @author A.Tselegidis <alextselegidis@gmail.com>
|
2021-12-18 19:43:45 +03:00
|
|
|
|
* @copyright Copyright (c) Alex Tselegidis
|
|
|
|
|
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
|
|
|
|
|
* @link https://easyappointments.org
|
2021-10-23 14:29:31 +03:00
|
|
|
|
* @since v1.5.0
|
2021-10-23 14:11:19 +03:00
|
|
|
|
* ---------------------------------------------------------------------------- */
|
|
|
|
|
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (!function_exists('env')) {
|
2021-10-23 14:11:19 +03:00
|
|
|
|
/**
|
|
|
|
|
* Gets the value of an environment variable.
|
|
|
|
|
*
|
|
|
|
|
* Example:
|
|
|
|
|
*
|
|
|
|
|
* $debug = env('debug', FALSE);
|
|
|
|
|
*
|
2023-11-29 12:24:09 +03:00
|
|
|
|
* @param string $key Environment key.
|
2023-03-13 11:06:18 +03:00
|
|
|
|
* @param mixed|null $default Default value in case the requested variable has no value.
|
2021-10-23 14:11:19 +03:00
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
2021-10-23 14:42:23 +03:00
|
|
|
|
*
|
|
|
|
|
* @throws InvalidArgumentException
|
2021-10-23 14:11:19 +03:00
|
|
|
|
*/
|
2023-11-29 12:24:09 +03:00
|
|
|
|
function env(string $key, mixed $default = null): mixed
|
2021-10-23 14:11:19 +03:00
|
|
|
|
{
|
2023-11-29 12:24:09 +03:00
|
|
|
|
if (empty($key)) {
|
2021-10-23 14:11:19 +03:00
|
|
|
|
throw new InvalidArgumentException('The $key argument cannot be empty.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $_ENV[$key] ?? $default;
|
|
|
|
|
}
|
|
|
|
|
}
|