src/ExtraConfigurator.php
public static function parseParameters(array $variables, string $prefix): array
	{
		$map = function (&$array, array $keys, $value) use (&$map) {
			if (count($keys) <= 0) return $value;

			$key = array_shift($keys);

			if (!is_array($array)) {
				throw new InvalidStateException(sprintf('Invalid structure for key "%s" value "%s"', implode($keys), $value));
			}

			if (!array_key_exists($key, $array)) {
				$array[$key] = [];
			}

			// Recursive
			$array[$key] = $map($array[$key], $keys, $value);

			return $array;
		};

		$parameters = [];
		foreach ($variables as $key => $value) {
			// Ensure value
			$value = getenv($key);
			if (strpos($key, $prefix) === 0 && $value !== false) {
				// Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N}
				$keys = static::parseParameter(substr($key, strlen($prefix)));
				// Make array structure
				$map($parameters, $keys, $value);
			}
		}

		return $parameters;
	}
public static function parseParameters(array $variables, string $prefix): array
	{
		$map = function (&$array, array $keys, $value) use (&$map) {
			if (count($keys) <= 0) return $value;

			$key = array_shift($keys);

			if (!is_array($array)) {
				throw new InvalidStateException(sprintf('Invalid structure for key "%s" value "%s"', implode($keys), $value));
			}

			if (!array_key_exists($key, $array)) {
				$array[$key] = [];
			}

			// Recursive
			$array[$key] = $map($array[$key], $keys, $value);

			return $array;
		};

		$parameters = [];
		foreach ($variables as $key => $value) {
			// Ensure value
			$value = getenv($key);
			if (strpos($key, $prefix) === 0 && $value !== false) {
				// Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N}
				$keys = static::parseParameter(substr($key, strlen($prefix)));
				// Make array structure
				$map($parameters, $keys, $value);
			}
		}

		return $parameters;
	}
public static function parseParameters ( array $ variables , string $ prefix ) : array { $ map = function ( & $ array , array $ keys , $ value ) use ( & $ map ) { if ( count ( $ keys ) <= 0 ) return $ value ; $ key = array_shift ( $ keys ) ; if ( ! is_array ( $ array ) ) { throw new InvalidStateException ( sprintf ( 'Invalid structure for key "%s" value "%s"' , implode ( $ keys ) , $ value ) ) ; } if ( ! array_key_exists ( $ key , $ array ) ) { $ array [ $ key ] = [ ] ; } // Recursive $ array [ $ key ] = $ map ( $ array [ $ key ] , $ keys , $ value ) ; return $ array ; } ; $ parameters = [ ] ; foreach ( $ variables as $ key => $ value ) { // Ensure value $ value = getenv ( $ key ) ; if ( strpos ( $ key , $ prefix ) === 0 && $ value !== false ) { // Parse PREFIX{delimiter=__}{NAME-1}{delimiter=__}{NAME-N} $ keys = static :: parseParameter ( substr ( $ key , strlen ( $ prefix ) ) ) ; // Make array structure $ map ( $ parameters , $ keys , $ value ) ; } } return $ parameters ; }
Parse given parameters with custom prefix

@param mixed[] $variables
@return mixed[]
Parse given parameters with custom prefix