Exemplo n.º 1
0
 /**
  * Gets the value of an environment variable. Supports boolean, empty and null.
  *
  * @param  string $key
  * @param  mixed  $default
  *
  * @return mixed
  */
 function env($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 (strlen($value) > 1 && Lib::starts_with('"', $value) && Lib::ends_with('"', $value)) {
         return substr($value, 1, -1);
     }
     return $value;
 }