@@ -58,7 +58,7 @@ |
||
| 58 | 58 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 59 | 59 | |
| 60 | 60 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 61 | - new class() implements LoaderInterface { |
|
| 61 | + new class() implements LoaderInterface{ |
|
| 62 | 62 | public function has(string $section): bool |
| 63 | 63 | { |
| 64 | 64 | return false; |
@@ -58,7 +58,8 @@ |
||
| 58 | 58 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 59 | 59 | |
| 60 | 60 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 61 | - new class() implements LoaderInterface { |
|
| 61 | + new class() implements LoaderInterface |
|
| 62 | + { |
|
| 62 | 63 | public function has(string $section): bool |
| 63 | 64 | { |
| 64 | 65 | return false; |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 41 | 41 | |
| 42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 43 | - new class() implements LoaderInterface { |
|
| 43 | + new class() implements LoaderInterface{ |
|
| 44 | 44 | public function has(string $section): bool |
| 45 | 45 | { |
| 46 | 46 | return false; |
@@ -40,7 +40,8 @@ |
||
| 40 | 40 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 41 | 41 | |
| 42 | 42 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 43 | - new class() implements LoaderInterface { |
|
| 43 | + new class() implements LoaderInterface |
|
| 44 | + { |
|
| 44 | 45 | public function has(string $section): bool |
| 45 | 46 | { |
| 46 | 47 | return false; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $container = new Container(); |
| 54 | 54 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 55 | - new class() implements LoaderInterface { |
|
| 55 | + new class() implements LoaderInterface{ |
|
| 56 | 56 | public function has(string $section): bool |
| 57 | 57 | { |
| 58 | 58 | return false; |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | { |
| 80 | 80 | $container = new Container(); |
| 81 | 81 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 82 | - new class() implements LoaderInterface { |
|
| 82 | + new class() implements LoaderInterface{ |
|
| 83 | 83 | public function has(string $section): bool |
| 84 | 84 | { |
| 85 | 85 | return false; |
@@ -52,7 +52,8 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $container = new Container(); |
| 54 | 54 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 55 | - new class() implements LoaderInterface { |
|
| 55 | + new class() implements LoaderInterface |
|
| 56 | + { |
|
| 56 | 57 | public function has(string $section): bool |
| 57 | 58 | { |
| 58 | 59 | return false; |
@@ -79,7 +80,8 @@ discard block |
||
| 79 | 80 | { |
| 80 | 81 | $container = new Container(); |
| 81 | 82 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 82 | - new class() implements LoaderInterface { |
|
| 83 | + new class() implements LoaderInterface |
|
| 84 | + { |
|
| 83 | 85 | public function has(string $section): bool |
| 84 | 86 | { |
| 85 | 87 | return false; |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 33 | 33 | |
| 34 | 34 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 35 | - new class() implements LoaderInterface { |
|
| 35 | + new class() implements LoaderInterface{ |
|
| 36 | 36 | public function has(string $section): bool |
| 37 | 37 | { |
| 38 | 38 | return false; |
@@ -32,7 +32,8 @@ |
||
| 32 | 32 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 33 | 33 | |
| 34 | 34 | $container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 35 | - new class() implements LoaderInterface { |
|
| 35 | + new class() implements LoaderInterface |
|
| 36 | + { |
|
| 36 | 37 | public function has(string $section): bool |
| 37 | 38 | { |
| 38 | 39 | return false; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 33 | 33 | |
| 34 | 34 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 35 | - new class() implements LoaderInterface { |
|
| 35 | + new class() implements LoaderInterface{ |
|
| 36 | 36 | public function has(string $section): bool |
| 37 | 37 | { |
| 38 | 38 | return false; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | ] |
| 84 | 84 | ])); |
| 85 | 85 | |
| 86 | - $logger = $this->container->get(LogsInterface::class)->getLogger('test');; |
|
| 86 | + $logger = $this->container->get(LogsInterface::class)->getLogger('test'); ; |
|
| 87 | 87 | |
| 88 | 88 | $this->assertCount(1, $logger->getProcessors()); |
| 89 | 89 | $this->assertInstanceOf(PsrLogMessageProcessor::class, $logger->getProcessors()[0]); |
@@ -32,7 +32,8 @@ |
||
| 32 | 32 | $finalizer->shouldReceive('addFinalizer')->once(); |
| 33 | 33 | |
| 34 | 34 | $this->container->bind(ConfiguratorInterface::class, new ConfigManager( |
| 35 | - new class() implements LoaderInterface { |
|
| 35 | + new class() implements LoaderInterface |
|
| 36 | + { |
|
| 36 | 37 | public function has(string $section): bool |
| 37 | 38 | { |
| 38 | 39 | return false; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | MonologConfig $config, |
| 52 | 52 | ListenerRegistryInterface $listenerRegistry, |
| 53 | 53 | FactoryInterface $factory |
| 54 | - ) { |
|
| 54 | + ){ |
|
| 55 | 55 | $this->config = $config; |
| 56 | 56 | $this->factory = $factory; |
| 57 | 57 | $this->eventHandler = new EventHandler($listenerRegistry, $config->getEventLevel()); |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getLogger(string $channel = null): LoggerInterface |
| 64 | 64 | { |
| 65 | - if ($channel === null || $channel == self::DEFAULT) { |
|
| 66 | - if ($this->default !== null) { |
|
| 65 | + if ($channel === null || $channel == self::DEFAULT){ |
|
| 66 | + if ($this->default !== null){ |
|
| 67 | 67 | // we should use only one default logger per system |
| 68 | 68 | return $this->default; |
| 69 | 69 | } |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | // always include default handler |
| 105 | 105 | $handlers = []; |
| 106 | 106 | |
| 107 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
| 108 | - if (! $handler instanceof Autowire) { |
|
| 107 | + foreach ($this->config->getHandlers($channel) as $handler){ |
|
| 108 | + if (!$handler instanceof Autowire){ |
|
| 109 | 109 | $handlers[] = $handler; |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - try { |
|
| 113 | + try{ |
|
| 114 | 114 | $handlers[] = $handler->resolve($this->factory); |
| 115 | - } catch (ContainerExceptionInterface $e) { |
|
| 115 | + }catch (ContainerExceptionInterface $e){ |
|
| 116 | 116 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | protected function getProcessors(string $channel): array |
| 132 | 132 | { |
| 133 | 133 | $processors = []; |
| 134 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
| 135 | - if (! $processor instanceof Autowire) { |
|
| 134 | + foreach ($this->config->getProcessors($channel) as $processor){ |
|
| 135 | + if (!$processor instanceof Autowire){ |
|
| 136 | 136 | $processors[] = $processor; |
| 137 | 137 | continue; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - try { |
|
| 140 | + try{ |
|
| 141 | 141 | $processors[] = $processor->resolve($this->factory); |
| 142 | - } catch (ContainerExceptionInterface $e) { |
|
| 142 | + }catch (ContainerExceptionInterface $e){ |
|
| 143 | 143 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - if ($processors === []) { |
|
| 147 | + if ($processors === []){ |
|
| 148 | 148 | $processors[] = new PsrLogMessageProcessor(); |
| 149 | 149 | } |
| 150 | 150 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | public function reset() |
| 155 | 155 | { |
| 156 | - if ($this->default instanceof ResettableInterface) { |
|
| 156 | + if ($this->default instanceof ResettableInterface){ |
|
| 157 | 157 | $this->default->reset(); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -62,8 +62,10 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getLogger(string $channel = null): LoggerInterface |
| 64 | 64 | { |
| 65 | - if ($channel === null || $channel == self::DEFAULT) { |
|
| 66 | - if ($this->default !== null) { |
|
| 65 | + if ($channel === null || $channel == self::DEFAULT) |
|
| 66 | + { |
|
| 67 | + if ($this->default !== null) |
|
| 68 | + { |
|
| 67 | 69 | // we should use only one default logger per system |
| 68 | 70 | return $this->default; |
| 69 | 71 | } |
@@ -104,15 +106,20 @@ discard block |
||
| 104 | 106 | // always include default handler |
| 105 | 107 | $handlers = []; |
| 106 | 108 | |
| 107 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
| 108 | - if (! $handler instanceof Autowire) { |
|
| 109 | + foreach ($this->config->getHandlers($channel) as $handler) |
|
| 110 | + { |
|
| 111 | + if (! $handler instanceof Autowire) |
|
| 112 | + { |
|
| 109 | 113 | $handlers[] = $handler; |
| 110 | 114 | continue; |
| 111 | 115 | } |
| 112 | 116 | |
| 113 | - try { |
|
| 117 | + try |
|
| 118 | + { |
|
| 114 | 119 | $handlers[] = $handler->resolve($this->factory); |
| 115 | - } catch (ContainerExceptionInterface $e) { |
|
| 120 | + } |
|
| 121 | + catch (ContainerExceptionInterface $e) |
|
| 122 | + { |
|
| 116 | 123 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 117 | 124 | } |
| 118 | 125 | } |
@@ -131,20 +138,26 @@ discard block |
||
| 131 | 138 | protected function getProcessors(string $channel): array |
| 132 | 139 | { |
| 133 | 140 | $processors = []; |
| 134 | - foreach ($this->config->getProcessors($channel) as $processor) { |
|
| 135 | - if (! $processor instanceof Autowire) { |
|
| 141 | + foreach ($this->config->getProcessors($channel) as $processor) |
|
| 142 | + { |
|
| 143 | + if (! $processor instanceof Autowire) |
|
| 144 | + { |
|
| 136 | 145 | $processors[] = $processor; |
| 137 | 146 | continue; |
| 138 | 147 | } |
| 139 | 148 | |
| 140 | - try { |
|
| 149 | + try |
|
| 150 | + { |
|
| 141 | 151 | $processors[] = $processor->resolve($this->factory); |
| 142 | - } catch (ContainerExceptionInterface $e) { |
|
| 152 | + } |
|
| 153 | + catch (ContainerExceptionInterface $e) |
|
| 154 | + { |
|
| 143 | 155 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
| 144 | 156 | } |
| 145 | 157 | } |
| 146 | 158 | |
| 147 | - if ($processors === []) { |
|
| 159 | + if ($processors === []) |
|
| 160 | + { |
|
| 148 | 161 | $processors[] = new PsrLogMessageProcessor(); |
| 149 | 162 | } |
| 150 | 163 | |
@@ -153,7 +166,8 @@ discard block |
||
| 153 | 166 | |
| 154 | 167 | public function reset() |
| 155 | 168 | { |
| 156 | - if ($this->default instanceof ResettableInterface) { |
|
| 169 | + if ($this->default instanceof ResettableInterface) |
|
| 170 | + { |
|
| 157 | 171 | $this->default->reset(); |
| 158 | 172 | } |
| 159 | 173 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | final class LogFactory implements LogsInterface, InjectorInterface, ResettableInterface |
| 29 | 29 | { |
| 30 | 30 | // Default logger channel (supplied via injection) |
| 31 | - public const DEFAULT = 'default'; |
|
| 31 | + public const default = 'default'; |
|
| 32 | 32 | |
| 33 | 33 | /** @var MonologConfig */ |
| 34 | 34 | private $config; |
@@ -62,16 +62,16 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function getLogger(string $channel = null): LoggerInterface |
| 64 | 64 | { |
| 65 | - if ($channel === null || $channel == self::DEFAULT) { |
|
| 65 | + if ($channel === null || $channel == self::default) { |
|
| 66 | 66 | if ($this->default !== null) { |
| 67 | 67 | // we should use only one default logger per system |
| 68 | 68 | return $this->default; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return $this->default = new Logger( |
| 72 | - self::DEFAULT, |
|
| 73 | - $this->getHandlers(self::DEFAULT), |
|
| 74 | - $this->getProcessors(self::DEFAULT) |
|
| 72 | + self::default, |
|
| 73 | + $this->getHandlers(self::default), |
|
| 74 | + $this->getProcessors(self::default) |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | public function boot(Container $container, FinalizerInterface $finalizer): void |
| 49 | 49 | { |
| 50 | 50 | $finalizer->addFinalizer(static function () use ($container): void { |
| 51 | - if ($container->hasInstance(LoggerInterface::class)) { |
|
| 51 | + if ($container->hasInstance(LoggerInterface::class)){ |
|
| 52 | 52 | $logger = $container->get(LoggerInterface::class); |
| 53 | 53 | |
| 54 | - if ($logger instanceof ResettableInterface) { |
|
| 54 | + if ($logger instanceof ResettableInterface){ |
|
| 55 | 55 | $logger->reset(); |
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - if ($container->hasInstance(LogsInterface::class)) { |
|
| 59 | + if ($container->hasInstance(LogsInterface::class)){ |
|
| 60 | 60 | $factory = $container->get(LogsInterface::class); |
| 61 | 61 | |
| 62 | - if ($factory instanceof ResettableInterface) { |
|
| 62 | + if ($factory instanceof ResettableInterface){ |
|
| 63 | 63 | $factory->reset(); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | $name = MonologConfig::CONFIG; |
| 79 | 79 | |
| 80 | - if (! isset($this->config->getConfig($name)['handlers'][$channel])) { |
|
| 80 | + if (!isset($this->config->getConfig($name)['handlers'][$channel])){ |
|
| 81 | 81 | $this->config->modify($name, new Append('handlers', $channel, [])); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -48,18 +48,22 @@ discard block |
||
| 48 | 48 | public function boot(Container $container, FinalizerInterface $finalizer): void |
| 49 | 49 | { |
| 50 | 50 | $finalizer->addFinalizer(static function () use ($container): void { |
| 51 | - if ($container->hasInstance(LoggerInterface::class)) { |
|
| 51 | + if ($container->hasInstance(LoggerInterface::class)) |
|
| 52 | + { |
|
| 52 | 53 | $logger = $container->get(LoggerInterface::class); |
| 53 | 54 | |
| 54 | - if ($logger instanceof ResettableInterface) { |
|
| 55 | + if ($logger instanceof ResettableInterface) |
|
| 56 | + { |
|
| 55 | 57 | $logger->reset(); |
| 56 | 58 | } |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | - if ($container->hasInstance(LogsInterface::class)) { |
|
| 61 | + if ($container->hasInstance(LogsInterface::class)) |
|
| 62 | + { |
|
| 60 | 63 | $factory = $container->get(LogsInterface::class); |
| 61 | 64 | |
| 62 | - if ($factory instanceof ResettableInterface) { |
|
| 65 | + if ($factory instanceof ResettableInterface) |
|
| 66 | + { |
|
| 63 | 67 | $factory->reset(); |
| 64 | 68 | } |
| 65 | 69 | } |
@@ -77,7 +81,8 @@ discard block |
||
| 77 | 81 | { |
| 78 | 82 | $name = MonologConfig::CONFIG; |
| 79 | 83 | |
| 80 | - if (! isset($this->config->getConfig($name)['handlers'][$channel])) { |
|
| 84 | + if (! isset($this->config->getConfig($name)['handlers'][$channel])) |
|
| 85 | + { |
|
| 81 | 86 | $this->config->modify($name, new Append('handlers', $channel, [])); |
| 82 | 87 | } |
| 83 | 88 | |