@@ -34,11 +34,13 @@ discard block |
||
34 | 34 | public function get($configuration) |
35 | 35 | { |
36 | 36 | |
37 | - if(!is_string($configuration)) |
|
38 | - throw new LamentException($configuration); |
|
37 | + if(!is_string($configuration)) { |
|
38 | + throw new LamentException($configuration); |
|
39 | + } |
|
39 | 40 | |
40 | - if($this->has($configuration)) |
|
41 | - return $this->configurations[$configuration]; |
|
41 | + if($this->has($configuration)) { |
|
42 | + return $this->configurations[$configuration]; |
|
43 | + } |
|
42 | 44 | |
43 | 45 | |
44 | 46 | // fallbacks |
@@ -47,17 +49,19 @@ discard block |
||
47 | 49 | $ret = $this->configurations; |
48 | 50 | foreach(explode('.', $configuration) as $k) |
49 | 51 | { |
50 | - if(!isset($ret[$k])) |
|
51 | - throw new ConfigurationException($configuration); |
|
52 | + if(!isset($ret[$k])) { |
|
53 | + throw new ConfigurationException($configuration); |
|
54 | + } |
|
52 | 55 | $ret = $ret[$k]; |
53 | 56 | } |
54 | 57 | |
55 | 58 | return $ret; |
56 | - } |
|
57 | - elseif(class_exists($configuration)) // auto create instances |
|
59 | + } elseif(class_exists($configuration)) { |
|
60 | + // auto create instances |
|
58 | 61 | { |
59 | 62 | |
60 | 63 | $rc = new \ReflectionClass($configuration); |
64 | + } |
|
61 | 65 | |
62 | 66 | $construction_args = []; |
63 | 67 | $instance = null; |
@@ -68,12 +72,13 @@ discard block |
||
68 | 72 | $construction_args []= $this->get($param->getType().''); |
69 | 73 | } |
70 | 74 | $instance = $rc->newInstanceArgs($construction_args); |
75 | + } else { |
|
76 | + $instance = $rc->newInstanceArgs(); |
|
71 | 77 | } |
72 | - else |
|
73 | - $instance = $rc->newInstanceArgs(); |
|
74 | 78 | |
75 | - if($rc->hasMethod('set_container')) |
|
76 | - $instance->set_container($this); |
|
79 | + if($rc->hasMethod('set_container')) { |
|
80 | + $instance->set_container($this); |
|
81 | + } |
|
77 | 82 | |
78 | 83 | return $instance; |
79 | 84 | } |