@@ -49,7 +49,7 @@ public function __construct($configDir, $fileName = 'config.php') {
4949 * @return array an array of key names
5050 */
5151 public function getKeys () {
52- return array_keys ($ this ->cache );
52+ return array_merge ( array_keys ($ this ->cache ), array_keys ( $ this -> envCache ) );
5353 }
5454
5555 /**
@@ -64,9 +64,8 @@ public function getKeys() {
6464 * @return mixed the value or $default
6565 */
6666 public function getValue ($ key , $ default = null ) {
67- $ envKey = self ::ENV_PREFIX . $ key ;
68- if (isset ($ this ->envCache [$ envKey ])) {
69- return $ this ->envCache [$ envKey ];
67+ if (isset ($ this ->envCache [$ key ])) {
68+ return $ this ->envCache [$ key ];
7069 }
7170
7271 if (isset ($ this ->cache [$ key ])) {
@@ -226,7 +225,16 @@ private function readData() {
226225 }
227226 }
228227
229- $ this ->envCache = getenv ();
228+ // grab any "NC_" environment variables
229+ $ envRaw = getenv ();
230+ // only save environment variables prefixed with "NC_" in the cache
231+ $ envPrefixLen = strlen (self ::ENV_PREFIX );
232+ foreach ($ envRaw as $ rawEnvKey => $ rawEnvValue ) {
233+ if (str_starts_with ($ rawEnvKey , self ::ENV_PREFIX )) {
234+ $ realKey = substr ($ rawEnvKey , $ envPrefixLen );
235+ $ this ->envCache [$ realKey ] = $ rawEnvValue ;
236+ }
237+ }
230238 }
231239
232240 /**
0 commit comments