Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Commit

Permalink
Cleaning code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Nov 2, 2018
1 parent 176e3bd commit 0795da0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class Config
public function __construct($config = null)
{
$data = new Data(self::$defaultData);

if ($config instanceof self) {
$data->importData($config->getAll());
} elseif (is_array($config)) {
Expand All @@ -146,15 +147,14 @@ public function __construct($config = null)
new \RecursiveArrayIterator($array),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $value) {
if (!$iterator->hasChildren()) {
for ($p = [], $i = 0, $z = $iterator->getDepth(); $i <= $z; $i++) {
$p[] = $iterator->getSubIterator($i)->key();
}
$path = implode('_', $p);
if ($getEnv = getenv('PHPOOLE_'.strtoupper($path))) {
$data->set(str_replace('_', '.', strtolower($path)), $getEnv);
}
foreach ($iterator as $leafValue) {
$path = [];
foreach (range(0, $iterator->getDepth()) as $depth) {
$path[] = $iterator->getSubIterator($depth)->key();
}
$sPath = implode('_', $path);
if ($getEnv = getenv('PHPOOLE_'.strtoupper($sPath))) {
$data->set(str_replace('_', '.', strtolower($sPath)), $getEnv);
}
}
};
Expand Down

0 comments on commit 0795da0

Please sign in to comment.