Skip to content

Commit e828133

Browse files
committed
Replaced array_walk() with foreach().
Add a more detailed exception message when a top-level key is missing. Fixed style in README.md.
1 parent 9f1e09a commit e828133

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Processor.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function processFile(array $config)
3333
// Find the expected params
3434
$expectedValues = $yamlParser->parse(file_get_contents($config['dist-file']));
3535
if (!isset($expectedValues[$parameterKey])) {
36-
throw new \InvalidArgumentException('The dist file seems invalid.');
36+
throw new \InvalidArgumentException(sprintf('The top-level key %s is missing.', $parameterKey));
3737
}
3838
$expectedParams = (array) $expectedValues[$parameterKey];
3939

@@ -104,9 +104,9 @@ private function processParams(array $config, array $expectedParams, array $actu
104104
if (!empty($config['env-map'])) {
105105
// Hydrate env-map from dist file
106106
if ('auto' === $config['env-map']) {
107-
array_walk($expectedParams, function($v, $k) use (&$envMap) {
108-
$envMap[$k] = strtoupper($k);
109-
});
107+
foreach ($expectedParams as $key => $value) {
108+
$envMap[$key] = strtoupper($key);
109+
}
110110
} else {
111111
$envMap = (array) $config['env-map'];
112112
}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ As environment variables can only be strings, they are also parsed as inline
122122
Yaml values to allows specifying ``null``, ``false``, ``true`` or numbers
123123
easily.
124124

125-
## Using same names for parameters and environment variables
125+
#### Using same names for parameters and environment variables
126126

127127
As an alternative, you can set environment variables with the same uppercased
128128
name of your dist parameters and use ``"env-map": "auto"`` to get an auto mapping.

Tests/ProcessorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function provideInvalidConfiguration()
7474
array(
7575
'file' => 'fixtures/invalid/missing_top_level.yml',
7676
),
77-
'The dist file seems invalid.',
77+
'The top-level key parameters is missing.',
7878
),
7979
'invalid values in the existing file' => array(
8080
array(

0 commit comments

Comments
 (0)