@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | public function __debugInfo() : array |
17 | 17 | { |
18 | 18 | $dbg = get_object_vars($this); |
19 | - $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine'])? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
19 | + $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine']) ? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
20 | 20 | |
21 | 21 | return $dbg; |
22 | 22 | } |
@@ -37,18 +37,18 @@ discard block |
||
37 | 37 | |
38 | 38 | $construction_args = []; |
39 | 39 | $instance = null; |
40 | - if(!is_null($rc->getConstructor())) |
|
40 | + if (!is_null($rc->getConstructor())) |
|
41 | 41 | { |
42 | - foreach($rc->getConstructor()->getParameters() as $param) |
|
42 | + foreach ($rc->getConstructor()->getParameters() as $param) |
|
43 | 43 | { |
44 | - $construction_args []= $this->get($param->getType().''); |
|
44 | + $construction_args [] = $this->get($param->getType().''); |
|
45 | 45 | } |
46 | 46 | $instance = $rc->newInstanceArgs($construction_args); |
47 | 47 | } |
48 | 48 | else |
49 | 49 | $instance = $rc->newInstanceArgs(); |
50 | 50 | |
51 | - if($rc->hasMethod('set_container')) |
|
51 | + if ($rc->hasMethod('set_container')) |
|
52 | 52 | $instance->set_container($this); |
53 | 53 | |
54 | 54 | return $instance; |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | $ret = $this->configurations; |
61 | 61 | |
62 | 62 | //dot based hierarchy, parse and climb |
63 | - foreach(explode('.', $setting) as $k) |
|
63 | + foreach (explode('.', $setting) as $k) |
|
64 | 64 | { |
65 | - if(!isset($ret[$k])) |
|
65 | + if (!isset($ret[$k])) |
|
66 | 66 | throw new ConfigurationException($setting); |
67 | 67 | $ret = $ret[$k]; |
68 | 68 | } |
@@ -73,21 +73,21 @@ discard block |
||
73 | 73 | public function get($configuration) |
74 | 74 | { |
75 | 75 | |
76 | - if(!is_string($configuration)) |
|
76 | + if (!is_string($configuration)) |
|
77 | 77 | throw new LamentException($configuration); |
78 | 78 | |
79 | - if($this->has($configuration)) |
|
79 | + if ($this->has($configuration)) |
|
80 | 80 | return $this->configurations[$configuration]; |
81 | 81 | |
82 | 82 | // fallbacks |
83 | 83 | // 1. configuration data |
84 | 84 | // 2. creating instances |
85 | 85 | |
86 | - if(preg_match('/^settings\./', $configuration, $m) === 1) |
|
86 | + if (preg_match('/^settings\./', $configuration, $m) === 1) |
|
87 | 87 | { |
88 | 88 | return $this->get_settings($configuration); |
89 | 89 | } |
90 | - elseif(class_exists($configuration)) // auto create instances |
|
90 | + elseif (class_exists($configuration)) // auto create instances |
|
91 | 91 | { |
92 | 92 | return $this->get_instance($configuration); |
93 | 93 | } |
@@ -44,12 +44,13 @@ discard block |
||
44 | 44 | $construction_args []= $this->get($param->getType().''); |
45 | 45 | } |
46 | 46 | $instance = $rc->newInstanceArgs($construction_args); |
47 | + } else { |
|
48 | + $instance = $rc->newInstanceArgs(); |
|
47 | 49 | } |
48 | - else |
|
49 | - $instance = $rc->newInstanceArgs(); |
|
50 | 50 | |
51 | - if($rc->hasMethod('set_container')) |
|
52 | - $instance->set_container($this); |
|
51 | + if($rc->hasMethod('set_container')) { |
|
52 | + $instance->set_container($this); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | return $instance; |
55 | 56 | } |
@@ -62,8 +63,9 @@ discard block |
||
62 | 63 | //dot based hierarchy, parse and climb |
63 | 64 | foreach(explode('.', $setting) as $k) |
64 | 65 | { |
65 | - if(!isset($ret[$k])) |
|
66 | - throw new ConfigurationException($setting); |
|
66 | + if(!isset($ret[$k])) { |
|
67 | + throw new ConfigurationException($setting); |
|
68 | + } |
|
67 | 69 | $ret = $ret[$k]; |
68 | 70 | } |
69 | 71 | |
@@ -73,11 +75,13 @@ discard block |
||
73 | 75 | public function get($configuration) |
74 | 76 | { |
75 | 77 | |
76 | - if(!is_string($configuration)) |
|
77 | - throw new LamentException($configuration); |
|
78 | + if(!is_string($configuration)) { |
|
79 | + throw new LamentException($configuration); |
|
80 | + } |
|
78 | 81 | |
79 | - if($this->has($configuration)) |
|
80 | - return $this->configurations[$configuration]; |
|
82 | + if($this->has($configuration)) { |
|
83 | + return $this->configurations[$configuration]; |
|
84 | + } |
|
81 | 85 | |
82 | 86 | // fallbacks |
83 | 87 | // 1. configuration data |
@@ -86,11 +90,12 @@ discard block |
||
86 | 90 | if(preg_match('/^settings\./', $configuration, $m) === 1) |
87 | 91 | { |
88 | 92 | return $this->get_settings($configuration); |
89 | - } |
|
90 | - elseif(class_exists($configuration)) // auto create instances |
|
93 | + } elseif(class_exists($configuration)) { |
|
94 | + // auto create instances |
|
91 | 95 | { |
92 | 96 | return $this->get_instance($configuration); |
93 | 97 | } |
98 | + } |
|
94 | 99 | |
95 | 100 | throw new ConfigurationException($configuration); |
96 | 101 | } |