/**
* Determine the value of a constant, if any.
*
- * If the specified constant is undefined, return a default value.
+ * If the specified constant is undefined, check for an environment
+ * variable, defaulting the passed in default value.
*
* @param string $name
* @param mixed $default
* (optional)
* @return mixed
*/
- public static function value($name, $default = NULL) {
+ public static function value(string $name, $default = NULL) {
if (defined($name)) {
return constant($name);
}
- else {
- return $default;
+ if (($value = getenv($name)) !== FALSE) {
+ define($name, $value);
+ return $value;
}
+ return $default;
}
}