@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | /** @var HandlerInterface $instance */ |
133 | 133 | $instance = $reflection->newInstanceArgs($parameters); |
134 | 134 | } else { |
135 | - $class = $handler['name']; |
|
135 | + $class = $handler['name']; |
|
136 | 136 | |
137 | 137 | /** @var HandlerInterface $instance */ |
138 | - $instance = new $class(); |
|
138 | + $instance = new $class(); |
|
139 | 139 | } |
140 | 140 | |
141 | - if (isset($handler['formatter'])) { |
|
142 | - $formatter = $this->createFormatter($container, $handler['formatter']); |
|
143 | - $instance->setFormatter($formatter); |
|
144 | - } |
|
141 | + if (isset($handler['formatter'])) { |
|
142 | + $formatter = $this->createFormatter($container, $handler['formatter']); |
|
143 | + $instance->setFormatter($formatter); |
|
144 | + } |
|
145 | 145 | |
146 | 146 | return $instance; |
147 | 147 | } |
@@ -155,34 +155,34 @@ discard block |
||
155 | 155 | * @throws \Interop\Container\Exception\ContainerException |
156 | 156 | * @throws RuntimeException |
157 | 157 | */ |
158 | - public function createFormatter($container, $formatter) |
|
159 | - { |
|
160 | - if (is_string($formatter) && $container->has($formatter)) { |
|
161 | - return $container->get($formatter); |
|
162 | - } else { |
|
163 | - if (!isset($formatter['name'])) { |
|
164 | - throw new RuntimeException('Cannot create logger formatter'); |
|
165 | - } |
|
166 | - |
|
167 | - if (!class_exists($formatter['name'])) { |
|
168 | - throw new RuntimeException('Cannot create logger formatter (' . $formatter['name'] . ')'); |
|
169 | - } |
|
170 | - |
|
171 | - if (isset($formatter['args'])) { |
|
172 | - if (!is_array($formatter['args'])) { |
|
173 | - throw new RuntimeException('Arguments of formatter(' . $formatter['name'] . ') must be array'); |
|
174 | - } |
|
175 | - |
|
176 | - $reflection = new \ReflectionClass($formatter['name']); |
|
177 | - |
|
178 | - return call_user_func_array(array($reflection, 'newInstance'), $formatter['args']); |
|
179 | - } |
|
180 | - |
|
181 | - $class = $formatter['name']; |
|
182 | - |
|
183 | - return new $class(); |
|
184 | - } |
|
185 | - } |
|
158 | + public function createFormatter($container, $formatter) |
|
159 | + { |
|
160 | + if (is_string($formatter) && $container->has($formatter)) { |
|
161 | + return $container->get($formatter); |
|
162 | + } else { |
|
163 | + if (!isset($formatter['name'])) { |
|
164 | + throw new RuntimeException('Cannot create logger formatter'); |
|
165 | + } |
|
166 | + |
|
167 | + if (!class_exists($formatter['name'])) { |
|
168 | + throw new RuntimeException('Cannot create logger formatter (' . $formatter['name'] . ')'); |
|
169 | + } |
|
170 | + |
|
171 | + if (isset($formatter['args'])) { |
|
172 | + if (!is_array($formatter['args'])) { |
|
173 | + throw new RuntimeException('Arguments of formatter(' . $formatter['name'] . ') must be array'); |
|
174 | + } |
|
175 | + |
|
176 | + $reflection = new \ReflectionClass($formatter['name']); |
|
177 | + |
|
178 | + return call_user_func_array(array($reflection, 'newInstance'), $formatter['args']); |
|
179 | + } |
|
180 | + |
|
181 | + $class = $formatter['name']; |
|
182 | + |
|
183 | + return new $class(); |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * @param ServiceLocatorInterface|ContainerInterface $container |