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