调整env函数位置

master
李春波 2 years ago
parent 38b0eef7ad
commit 16bdeab15b
  1. 31
      app/functions.php
  2. 31
      support/helpers.php

@ -3,6 +3,37 @@
* 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) {

@ -515,34 +515,3 @@ function cpu_count(): int
}
return $count > 0 ? $count : 4;
}
/**
* @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;
}
Loading…
Cancel
Save