@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | MonologConfig $config, |
51 | 51 | ListenerRegistryInterface $listenerRegistry, |
52 | 52 | FactoryInterface $factory |
53 | - ) { |
|
53 | + ){ |
|
54 | 54 | $this->config = $config; |
55 | 55 | $this->factory = $factory; |
56 | 56 | $this->eventHandler = new EventHandler($listenerRegistry, $config->getEventLevel()); |
@@ -61,8 +61,8 @@ 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 | + if ($this->default !== null){ |
|
66 | 66 | // we should use only one default logger per system |
67 | 67 | return $this->default; |
68 | 68 | } |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | // always include default handler |
104 | 104 | $handlers = []; |
105 | 105 | |
106 | - foreach ($this->config->getHandlers($channel) as $handler) { |
|
107 | - if (!$handler instanceof Autowire) { |
|
106 | + foreach ($this->config->getHandlers($channel) as $handler){ |
|
107 | + if (!$handler instanceof Autowire){ |
|
108 | 108 | $handlers[] = $handler; |
109 | 109 | continue; |
110 | 110 | } |
111 | 111 | |
112 | - try { |
|
112 | + try{ |
|
113 | 113 | $handlers[] = $handler->resolve($this->factory); |
114 | - } catch (ContainerExceptionInterface $e) { |
|
114 | + }catch (ContainerExceptionInterface $e){ |
|
115 | 115 | throw new ConfigException($e->getMessage(), $e->getCode(), $e); |
116 | 116 | } |
117 | 117 | } |
@@ -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 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | final class LogFactory implements LogsInterface, InjectorInterface |
28 | 28 | { |
29 | 29 | // Default logger channel (supplied via injection) |
30 | - public const DEFAULT = 'default'; |
|
30 | + public const default = 'default'; |
|
31 | 31 | |
32 | 32 | /** @var MonologConfig */ |
33 | 33 | private $config; |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function getLogger(string $channel = null): LoggerInterface |
63 | 63 | { |
64 | - if ($channel === null || $channel == self::DEFAULT) { |
|
64 | + if ($channel === null || $channel == self::default) { |
|
65 | 65 | if ($this->default !== null) { |
66 | 66 | // we should use only one default logger per system |
67 | 67 | return $this->default; |
68 | 68 | } |
69 | 69 | |
70 | 70 | return $this->default = new Logger( |
71 | - self::DEFAULT, |
|
72 | - $this->getHandlers(self::DEFAULT), |
|
73 | - $this->getProcessors(self::DEFAULT) |
|
71 | + self::default, |
|
72 | + $this->getHandlers(self::default), |
|
73 | + $this->getProcessors(self::default) |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 |
@@ -64,12 +64,12 @@ |
||
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 | $this->config->modify('monolog', new Append('handlers', $channel, [])); |
69 | 69 | } |
70 | 70 | |
71 | 71 | $this->config->modify('monolog', new Append( |
72 | - 'handlers.' . $channel, |
|
72 | + 'handlers.'.$channel, |
|
73 | 73 | null, |
74 | 74 | $handler |
75 | 75 | )); |
@@ -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 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | ListenerRegistryInterface $listenerRegistry, |
31 | 31 | int $level = Logger::DEBUG, |
32 | 32 | bool $bubble = true |
33 | - ) { |
|
33 | + ){ |
|
34 | 34 | $this->listenerRegistry = $listenerRegistry; |
35 | 35 | |
36 | 36 | parent::__construct($level, $bubble); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $record['context'] |
51 | 51 | ); |
52 | 52 | |
53 | - foreach ($this->listenerRegistry->getListeners() as $listener) { |
|
53 | + foreach ($this->listenerRegistry->getListeners() as $listener){ |
|
54 | 54 | call_user_func($listener, $e); |
55 | 55 | } |
56 | 56 | } |
@@ -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,18 @@ 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 | return; |
47 | 47 | } |
48 | 48 | |
49 | - foreach ($this->config['handlers'][$channel] as $handler) { |
|
50 | - if (is_object($handler) && !$handler instanceof Autowire) { |
|
49 | + foreach ($this->config['handlers'][$channel] as $handler){ |
|
50 | + if (is_object($handler) && !$handler instanceof Autowire){ |
|
51 | 51 | yield $handler; |
52 | 52 | continue; |
53 | 53 | } |
54 | 54 | |
55 | 55 | $wire = $this->wire($channel, $handler); |
56 | - if (!empty($wire)) { |
|
56 | + if (!empty($wire)){ |
|
57 | 57 | yield $wire; |
58 | 58 | } |
59 | 59 | } |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | */ |
69 | 69 | private function wire(string $channel, $handler): ?Autowire |
70 | 70 | { |
71 | - if ($handler instanceof Autowire) { |
|
71 | + if ($handler instanceof Autowire){ |
|
72 | 72 | return $handler; |
73 | 73 | } |
74 | 74 | |
75 | - if (is_string($handler)) { |
|
75 | + if (is_string($handler)){ |
|
76 | 76 | return new Autowire($handler); |
77 | 77 | } |
78 | 78 | |
79 | - if (isset($handler['class'])) { |
|
79 | + if (isset($handler['class'])){ |
|
80 | 80 | return new Autowire($handler['class'], $handler['options'] ?? []); |
81 | 81 | } |
82 | 82 |
@@ -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,7 @@ |
||
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 | public function has(string $section): bool |
58 | 58 | { |
59 | 59 | return false; |
@@ -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,7 @@ |
||
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 | public function has(string $section): bool |
48 | 48 | { |
49 | 49 | 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; |
@@ -33,7 +33,7 @@ |
||
33 | 33 | |
34 | 34 | $this->assertNotEmpty($logger); |
35 | 35 | $this->assertSame($logger, $factory->getLogger()); |
36 | - $this->assertSame($logger, $factory->getLogger(LogFactory::DEFAULT)); |
|
36 | + $this->assertSame($logger, $factory->getLogger(LogFactory::default)); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function testInjection(): void |
@@ -35,7 +35,7 @@ |
||
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 | public function has(string $section): bool |
40 | 40 | { |
41 | 41 | 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,7 @@ |
||
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 | public function has(string $section): bool |
32 | 32 | { |
33 | 33 | 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; |