Merge pull request #24032 from seamuslee001/remove_dependency_strftime
[civicrm-core.git] / CRM / Utils / Constant.php
index 5d941207e4acd50421e157fab187385fd643370d..253c743a8ba1f01c087719102ea4fcbef77909d3 100644 (file)
@@ -23,20 +23,23 @@ class CRM_Utils_Constant {
   /**
    * 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;
   }
 
 }