diff --git a/app/functions.php b/app/functions.php index 0defc34..31b03a0 100644 --- a/app/functions.php +++ b/app/functions.php @@ -3,37 +3,6 @@ * Here is your custom functions. */ -/** - * @param string $key - * @param $default - * @return array|bool|mixed|string|null - */ -function env(string $key, $default = null) -{ - $value = getenv($key); - if ($value === false) { - return value($default); - } - switch (strtolower($value)) { - case 'true': - case '(true)': - return true; - case 'false': - case '(false)': - return false; - case 'empty': - case '(empty)': - return ''; - case 'null': - case '(null)': - return null; - } - if (($valueLength = strlen($value)) > 1 && $value[0] === '"' && $value[$valueLength - 1] === '"') { - return substr($value, 1, -1); - } - return $value; -} - function success($data = [], $code = 0, $msg = '操作成功', $is_array = false) { if ($is_array) { diff --git a/composer.json b/composer.json index 33b0d11..1f61ccd 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,8 @@ "app\\View\\Components\\": "./app/view/components" }, "files": [ - "./support/helpers.php" + "./support/helpers.php", + "./support/initialization.php" ] }, "scripts": { diff --git a/support/initialization.php b/support/initialization.php new file mode 100644 index 0000000..d46c057 --- /dev/null +++ b/support/initialization.php @@ -0,0 +1,32 @@ + 1 && $value[0] === '"' && $value[$valueLength - 1] === '"') { + return substr($value, 1, -1); + } + return $value; +}