@@ -38,16 +38,16 @@ |
||
38 | 38 | |
39 | 39 | public function register(Application $app) |
40 | 40 | { |
41 | - $app['config'] = $app->share(function () |
|
41 | + $app['config'] = $app->share(function() |
|
42 | 42 | { |
43 | 43 | if ($this->cache_dir) |
44 | 44 | { |
45 | 45 | $cache = $this->getConfigCacheFactory()->cache($this->cache_dir.'/config.cache.php', |
46 | - function (ConfigCacheInterface $cache) |
|
46 | + function(ConfigCacheInterface $cache) |
|
47 | 47 | { |
48 | 48 | $config = $this->loadConfig(); |
49 | 49 | |
50 | - $content = sprintf('<?php use Junker\Silex\Config; $c = new Config(%s);', var_export($config->data, TRUE)) . PHP_EOL; |
|
50 | + $content = sprintf('<?php use Junker\Silex\Config; $c = new Config(%s);', var_export($config->data, TRUE)).PHP_EOL; |
|
51 | 51 | $content .= 'return $c;'; |
52 | 52 | |
53 | 53 | $cache->write($content, $config->getResources()); |
@@ -26,11 +26,13 @@ discard block |
||
26 | 26 | { |
27 | 27 | if (is_array($options)) |
28 | 28 | { |
29 | - if (isset($options['cache_dir'])) |
|
30 | - $this->cache_dir = $options['cache_dir']; |
|
29 | + if (isset($options['cache_dir'])) { |
|
30 | + $this->cache_dir = $options['cache_dir']; |
|
31 | + } |
|
31 | 32 | |
32 | - if (isset($options['debug'])) |
|
33 | - $this->debug = $options['debug']; |
|
33 | + if (isset($options['debug'])) { |
|
34 | + $this->debug = $options['debug']; |
|
35 | + } |
|
34 | 36 | } |
35 | 37 | |
36 | 38 | $this->file = $file; |
@@ -55,8 +57,7 @@ discard block |
||
55 | 57 | ); |
56 | 58 | |
57 | 59 | $config = include $cache->getPath(); |
58 | - } |
|
59 | - else |
|
60 | + } else |
|
60 | 61 | { |
61 | 62 | $config = $this->loadConfig(); |
62 | 63 | } |
@@ -67,7 +67,7 @@ |
||
67 | 67 | return $data; |
68 | 68 | } |
69 | 69 | |
70 | - private function parseImports(Config &$config, $file) |
|
70 | + private function parseImports(Config&$config, $file) |
|
71 | 71 | { |
72 | 72 | |
73 | 73 |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | $data = $this->loadFile($path); |
24 | 24 | |
25 | 25 | // empty file |
26 | - if ($data === NULL) |
|
27 | - $data = array(); |
|
26 | + if ($data === NULL) { |
|
27 | + $data = array(); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | // not an array |
30 | 31 | if (!is_array($data)) |
@@ -43,23 +44,26 @@ discard block |
||
43 | 44 | |
44 | 45 | protected function loadFile($file) |
45 | 46 | { |
46 | - if (!class_exists('Symfony\Component\Yaml\Parser')) |
|
47 | - throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.'); |
|
47 | + if (!class_exists('Symfony\Component\Yaml\Parser')) { |
|
48 | + throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.'); |
|
49 | + } |
|
48 | 50 | |
49 | - if (!stream_is_local($file)) |
|
50 | - throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file)); |
|
51 | + if (!stream_is_local($file)) { |
|
52 | + throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file)); |
|
53 | + } |
|
51 | 54 | |
52 | - if (!file_exists($file)) |
|
53 | - throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); |
|
55 | + if (!file_exists($file)) { |
|
56 | + throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file)); |
|
57 | + } |
|
54 | 58 | |
55 | - if ($this->yamlParser === NULL) |
|
56 | - $this->yamlParser = new YamlParser(); |
|
59 | + if ($this->yamlParser === NULL) { |
|
60 | + $this->yamlParser = new YamlParser(); |
|
61 | + } |
|
57 | 62 | |
58 | 63 | try |
59 | 64 | { |
60 | 65 | $data = $this->yamlParser->parse(file_get_contents($file)); |
61 | - } |
|
62 | - catch (ParseException $e) |
|
66 | + } catch (ParseException $e) |
|
63 | 67 | { |
64 | 68 | throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e); |
65 | 69 | } |
@@ -84,8 +88,9 @@ discard block |
||
84 | 88 | |
85 | 89 | foreach ($config->data['imports'] as $import) |
86 | 90 | { |
87 | - if (!is_array($import)) |
|
88 | - throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); |
|
91 | + if (!is_array($import)) { |
|
92 | + throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file)); |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $this->setCurrentDir($defaultDirectory); |
91 | 96 | $sub_config = $this->import($import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file); |