| Total Complexity | 11 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | final class MonologConfig extends InjectableConfig |
||
| 20 | { |
||
| 21 | public const CONFIG = 'monolog'; |
||
| 22 | |||
| 23 | /** @var array */ |
||
| 24 | protected $config = [ |
||
| 25 | 'globalLevel' => Logger::DEBUG, |
||
| 26 | 'handlers' => [] |
||
| 27 | ]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @return int |
||
| 31 | */ |
||
| 32 | public function getEventLevel(): int |
||
| 33 | { |
||
| 34 | return $this->config['globalLevel'] ?? Logger::DEBUG; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $channel |
||
| 39 | * @return \Generator|Autowire[] |
||
| 40 | * |
||
| 41 | * @throws ConfigException |
||
| 42 | */ |
||
| 43 | public function getHandlers(string $channel): \Generator |
||
| 44 | { |
||
| 45 | if (empty($this->config['handlers'][$channel])) { |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | foreach ($this->config['handlers'][$channel] as $handler) { |
||
| 50 | if (is_object($handler) && !$handler instanceof Autowire) { |
||
| 51 | yield $handler; |
||
| 52 | continue; |
||
| 53 | } |
||
| 54 | |||
| 55 | $wire = $this->wire($channel, $handler); |
||
| 56 | if (!empty($wire)) { |
||
| 57 | yield $wire; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param string $channel |
||
| 64 | * @param mixed $handler |
||
| 65 | * @return null|Autowire |
||
| 66 | * |
||
| 67 | * @throws ConfigException |
||
| 68 | */ |
||
| 69 | private function wire(string $channel, $handler): ?Autowire |
||
| 84 | } |
||
| 85 | } |
||
| 86 |