@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | // Working from the first key, descend into the array until nothing is found |
| 13 | 13 | return array_reduce( |
| 14 | 14 | explode('.', $dotPath), |
| 15 | - function ($config, $key) use ($default) { |
|
| 15 | + function($config, $key) use ($default) { |
|
| 16 | 16 | return isset($config[$key]) ? $config[$key] : $default; |
| 17 | 17 | }, |
| 18 | 18 | $config |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | // Work backward from the last key, wrapping each key in an array |
| 28 | 28 | $replace = array_reduce( |
| 29 | 29 | array_reverse(explode('.', $dotPath)), |
| 30 | - function ($value, $key) { |
|
| 30 | + function($value, $key) { |
|
| 31 | 31 | return [$key => $value]; |
| 32 | 32 | }, |
| 33 | 33 | $value |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | * alternative to var_export that exports an array to short array syntax |
| 42 | 42 | * copyright disclaimer: orignally written by stemar: [https://gist.github.com/stemar/bb7c5cd2614b21b624bf57608f995ac0] |
| 43 | 43 | */ |
| 44 | -function varexport($expression, $return=FALSE) { |
|
| 44 | +function varexport($expression, $return = FALSE) { |
|
| 45 | 45 | $export = var_export($expression, TRUE); |
| 46 | 46 | $export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export); |
| 47 | 47 | $array = preg_split("/\r\n|\n|\r/", $export); |
| 48 | 48 | $array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array); |
| 49 | 49 | $export = join(PHP_EOL, array_filter(["["] + $array)); |
| 50 | - if ((bool)$return) return $export; else echo $export; |
|
| 50 | + if ((bool) $return) return $export; else echo $export; |
|
| 51 | 51 | } |
@@ -47,5 +47,9 @@ |
||
| 47 | 47 | $array = preg_split("/\r\n|\n|\r/", $export); |
| 48 | 48 | $array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [NULL, ']$1', ' => ['], $array); |
| 49 | 49 | $export = join(PHP_EOL, array_filter(["["] + $array)); |
| 50 | - if ((bool)$return) return $export; else echo $export; |
|
| 51 | -} |
|
| 50 | + if ((bool)$return) { |
|
| 51 | + return $export; |
|
| 52 | + } else { |
|
| 53 | + echo $export; |
|
| 54 | + } |
|
| 55 | + } |
|
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | |
| 47 | 47 | if (is_array($value)) { |
| 48 | 48 | return array_map( |
| 49 | - function ($value) { |
|
| 49 | + function($value) { |
|
| 50 | 50 | return $this->replaceVariables($value); |
| 51 | 51 | }, |
| 52 | 52 | $value |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | |
| 26 | 26 | private function reducer(string $dotPath): callable |
| 27 | 27 | { |
| 28 | - return static function ($currentValue, ConfigInterface $config) use ($dotPath) { |
|
| 28 | + return static function($currentValue, ConfigInterface $config) use ($dotPath) { |
|
| 29 | 29 | $found = $config->get($dotPath, null); |
| 30 | 30 | |
| 31 | 31 | if ($found === null) { |
@@ -23,11 +23,11 @@ |
||
| 23 | 23 | public function unload(string $path, array $data) |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - if ( is_file("{$path}.php") && !copy("{$path}.php", "{$path}.backup.php") ) { |
|
| 26 | + if (is_file("{$path}.php") && !copy("{$path}.php", "{$path}.backup.php")) { |
|
| 27 | 27 | throw LoaderException::backupFail(static::class); |
| 28 | 28 | } |
| 29 | 29 | $filename = basename($path); |
| 30 | 30 | |
| 31 | - file_put_contents("{$path}.php" , "<?php " . PHP_EOL . " return " . \Northwoods\Config\varexport($data[$filename], true) . ';' . PHP_EOL); |
|
| 31 | + file_put_contents("{$path}.php", "<?php ".PHP_EOL." return ".\Northwoods\Config\varexport($data[$filename], true).';'.PHP_EOL); |
|
| 32 | 32 | } |
| 33 | 33 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function testDirectory() |
| 20 | 20 | { |
| 21 | 21 | $config = ConfigFactory::make([ |
| 22 | - 'directory' => __DIR__ . '/../examples', |
|
| 22 | + 'directory' => __DIR__.'/../examples', |
|
| 23 | 23 | ]); |
| 24 | 24 | |
| 25 | 25 | // it implements the configuration interfaces |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // in order to make the test run smoothly i will change the filename |
| 48 | 48 | $config->set('customSafe.dynamic.key', 'value', true); |
| 49 | 49 | $config = ConfigFactory::make([ |
| 50 | - 'directory' => __DIR__ . '/../examples', |
|
| 50 | + 'directory' => __DIR__.'/../examples', |
|
| 51 | 51 | ]); |
| 52 | 52 | $this->assertSame('value', $config->get('customSafe.dynamic.key')); |
| 53 | 53 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function testEnvironment() |
| 57 | 57 | { |
| 58 | 58 | $config = ConfigFactory::make([ |
| 59 | - 'directory' => __DIR__ . '/../examples', |
|
| 59 | + 'directory' => __DIR__.'/../examples', |
|
| 60 | 60 | 'environment' => 'dev', |
| 61 | 61 | ]); |
| 62 | 62 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | // new environments can be created |
| 78 | 78 | $config = ConfigFactory::make([ |
| 79 | - 'directory' => __DIR__ . '/../examples', |
|
| 79 | + 'directory' => __DIR__.'/../examples', |
|
| 80 | 80 | 'environment' => 'prod', |
| 81 | 81 | ]); |
| 82 | 82 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | public function testYamlDirectory() |
| 99 | 99 | { |
| 100 | 100 | $config = ConfigFactory::make([ |
| 101 | - 'directory' => __DIR__ . '/../examples', |
|
| 101 | + 'directory' => __DIR__.'/../examples', |
|
| 102 | 102 | 'environment' => 'dev', |
| 103 | 103 | 'type' => 'yaml', |
| 104 | 104 | ]); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | // new environments can be created |
| 122 | 122 | $config = ConfigFactory::make([ |
| 123 | - 'directory' => __DIR__ . '/../examples', |
|
| 123 | + 'directory' => __DIR__.'/../examples', |
|
| 124 | 124 | 'environment' => 'prod', |
| 125 | 125 | 'type' => 'yaml', |
| 126 | 126 | ]); |