Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Wolf committed Jul 20, 2015
2 parents aed62a8 + d093240 commit 0e9edc1
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/Detail/VarCrypt/MultiEncryptor.php
Expand Up @@ -30,11 +30,7 @@ public function applyVariables($groups, $separator = '_')
foreach ($groups as $group) {
$values = $this->getVariables($group);

foreach ($values as $variable => $value) {
$name = $group . $separator . $variable;

$this->setEnvironmentVariable($name, $value);
}
$this->setEnvironmentVariables($values, $group, $separator);
}
}

Expand Down Expand Up @@ -112,6 +108,26 @@ public function decode($value)
return $values;
}

/**
* Recursively set environment variables (for each leaf).
*
* @param array $values
* @param string $prefix
* @param string $separator
*/
protected function setEnvironmentVariables(array $values, $prefix, $separator = '_')
{
foreach ($values as $variable => $value) {
$name = $prefix . $separator . $variable;

if (is_array($value)) {
$this->setEnvironmentVariables($value, $name, $separator);
} else {
$this->setEnvironmentVariable($name, $value);
}
}
}

/**
* @param string $errorMessage
*/
Expand Down

0 comments on commit 0e9edc1

Please sign in to comment.