protected function resolveNestedVariables(string $value): string
	{
		if (strpos($value, '$') !== false)
		{
			$loader = $this;

			$value = preg_replace_callback(
				'/\${([a-zA-Z0-9_]+)}/',
				function ($matchedPatterns) use ($loader) {
					$nestedVariable = $loader->getVariable($matchedPatterns[1]);

					if (is_null($nestedVariable))
					{
						return $matchedPatterns[0];
					}

					return $nestedVariable;
				},
				$value
			);
		}

		return $value;
	}
protected function resolveNestedVariables(string $value): string
	{
		if (strpos($value, '$') !== false)
		{
			$loader = $this;

			$value = preg_replace_callback(
				'/\${([a-zA-Z0-9_]+)}/',
				function ($matchedPatterns) use ($loader) {
					$nestedVariable = $loader->getVariable($matchedPatterns[1]);

					if (is_null($nestedVariable))
					{
						return $matchedPatterns[0];
					}

					return $nestedVariable;
				},
				$value
			);
		}

		return $value;
	}
protected function resolveNestedVariables ( string $ value ) : string { if ( strpos ( $ value , '$' ) !== false ) { $ loader = $ this ; $ value = preg_replace_callback ( '/\${([a-zA-Z0-9_]+)}/' , function ( $ matchedPatterns ) use ( $ loader ) { $ nestedVariable = $ loader -> getVariable ( $ matchedPatterns [ 1 ] ) ; if ( is_null ( $ nestedVariable ) ) { return $ matchedPatterns [ 0 ] ; } return $ nestedVariable ; } , $ value ) ; } return $ value ; }
Resolve the nested variables.

Look for ${varname} patterns in the variable value and replace with an existing
environment variable.

This was borrowed from the excellent phpdotenv with very few changes.
https://github.com/vlucas/phpdotenv

@param $value

@return string
Resolve the nested variables .