@@ -61,8 +61,10 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getLogger(string $channel = null): LoggerInterface |
| 63 | 63 | { |
| 64 | - if ($channel === null || $channel == self::DEFAULT) { |
|
| 65 | - if ($this->default !== null) { |
|
| 64 | + if ($channel === null || $channel == self::DEFAULT) |
|
| 65 | + { |
|
| 66 | + if ($this->default !== null) |
|
| 67 | + { |
|
| 66 | 68 | // we should use only one default logger per system |
| 67 | 69 | return $this->default; |
| 68 | 70 | } |
@@ -103,15 +105,20 @@ discard block |
||
| 103 | 105 | // always include default handler |
| 104 | 106 | $handlers = []; |
| 105 | 107 | |
| 106 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
| 107 | - if (!$handler instanceof Autowire) { |
|
| 108 | + foreach ($this->config->getHandlers($channel) as $handler) |
|
| 109 | + { |
|
| 110 | + if (!$handler instanceof Autowire) |
|
| 111 | + { |
|
| 108 | 112 | $handlers[] = $handler; |
| 109 | 113 | continue; |
| 110 | 114 | } |
| 111 | 115 | |
| 112 | - try { |
|
| 116 | + try |
|
| 117 | + { |
|
| 113 | 118 | $handlers[] = $handler->resolve($this->factory); |
| 114 | - } catch (ContainerExceptionInterface $e) { |
|
| 119 | + } |
|
| 120 | + catch (ContainerExceptionInterface $e) |
|
| 121 | + { |
|
| 115 | 122 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 116 | 123 | } |
| 117 | 124 | } |
@@ -64,7 +64,8 @@ |
||
| 64 | 64 | */ |
| 65 | 65 | public function addHandler(string $channel, HandlerInterface $handler): void |
| 66 | 66 | { |
| 67 | - if (!isset($this->config->getConfig('monolog')['handlers'][$channel])) { |
|
| 67 | + if (!isset($this->config->getConfig('monolog')['handlers'][$channel])) |
|
| 68 | + { |
|
| 68 | 69 | $this->config->modify('monolog', new Append('handlers', $channel, [])); |
| 69 | 70 | } |
| 70 | 71 | |
@@ -50,7 +50,8 @@ |
||
| 50 | 50 | $record['context'] |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - foreach ($this->listenerRegistry->getListeners() as $listener) { |
|
| 53 | + foreach ($this->listenerRegistry->getListeners() as $listener) |
|
| 54 | + { |
|
| 54 | 55 | call_user_func($listener, $e); |
| 55 | 56 | } |
| 56 | 57 | } |
@@ -42,18 +42,22 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function getHandlers(string $channel): \Generator |
| 44 | 44 | { |
| 45 | - if (empty($this->config['handlers'][$channel])) { |
|
| 45 | + if (empty($this->config['handlers'][$channel])) |
|
| 46 | + { |
|
| 46 | 47 | return; |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - foreach ($this->config['handlers'][$channel] as $handler) { |
|
| 50 | - if (is_object($handler) && !$handler instanceof Autowire) { |
|
| 50 | + foreach ($this->config['handlers'][$channel] as $handler) |
|
| 51 | + { |
|
| 52 | + if (is_object($handler) && !$handler instanceof Autowire) |
|
| 53 | + { |
|
| 51 | 54 | yield $handler; |
| 52 | 55 | continue; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | $wire = $this->wire($channel, $handler); |
| 56 | - if (!empty($wire)) { |
|
| 59 | + if (!empty($wire)) |
|
| 60 | + { |
|
| 57 | 61 | yield $wire; |
| 58 | 62 | } |
| 59 | 63 | } |
@@ -68,15 +72,18 @@ discard block |
||
| 68 | 72 | */ |
| 69 | 73 | private function wire(string $channel, $handler): ?Autowire |
| 70 | 74 | { |
| 71 | - if ($handler instanceof Autowire) { |
|
| 75 | + if ($handler instanceof Autowire) |
|
| 76 | + { |
|
| 72 | 77 | return $handler; |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | - if (is_string($handler)) { |
|
| 80 | + if (is_string($handler)) |
|
| 81 | + { |
|
| 76 | 82 | return new Autowire($handler); |
| 77 | 83 | } |
| 78 | 84 | |
| 79 | - if (isset($handler['class'])) { |
|
| 85 | + if (isset($handler['class'])) |
|
| 86 | + { |
|
| 80 | 87 | return new Autowire($handler['class'], $handler['options'] ?? []); |
| 81 | 88 | } |
| 82 | 89 | |
@@ -53,7 +53,8 @@ |
||
| 53 | 53 | { |
| 54 | 54 | $container = new Container(); |
| 55 | 55 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 56 | - new class() implements LoaderInterface { |
|
| 56 | + new class() implements LoaderInterface |
|
| 57 | + { |
|
| 57 | 58 | public function has(string $section): bool |
| 58 | 59 | { |
| 59 | 60 | return false; |
@@ -43,7 +43,8 @@ |
||
| 43 | 43 | |
| 44 | 44 | $container = new Container(); |
| 45 | 45 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 46 | - new class() implements LoaderInterface { |
|
| 46 | + new class() implements LoaderInterface |
|
| 47 | + { |
|
| 47 | 48 | public function has(string $section): bool |
| 48 | 49 | { |
| 49 | 50 | return false; |
@@ -35,7 +35,8 @@ |
||
| 35 | 35 | { |
| 36 | 36 | $this->container = new Container(); |
| 37 | 37 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 38 | - new class() implements LoaderInterface { |
|
| 38 | + new class() implements LoaderInterface |
|
| 39 | + { |
|
| 39 | 40 | public function has(string $section): bool |
| 40 | 41 | { |
| 41 | 42 | return false; |
@@ -27,7 +27,8 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $container = new Container(); |
| 29 | 29 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 30 | - new class() implements LoaderInterface { |
|
| 30 | + new class() implements LoaderInterface |
|
| 31 | + { |
|
| 31 | 32 | public function has(string $section): bool |
| 32 | 33 | { |
| 33 | 34 | return false; |