1 | <?php |
||
8 | class MainConfig |
||
9 | { |
||
10 | /** @var HandlerConfig[] */ |
||
11 | protected $handlers = []; |
||
12 | |||
13 | /** @var FormatterConfig[] */ |
||
14 | protected $formatters = []; |
||
15 | |||
16 | /** @var ChannelConfig[] */ |
||
17 | protected $channels = []; |
||
18 | |||
19 | /** @var ProcessorConfig[] */ |
||
20 | protected $processors = []; |
||
21 | |||
22 | 18 | public function __construct(array $config) |
|
30 | |||
31 | /** |
||
32 | * @return HandlerConfig[] |
||
33 | */ |
||
34 | 1 | public function getHandlers() |
|
38 | |||
39 | 1 | public function hasHandlerConfig($handler) : bool |
|
40 | { |
||
41 | 1 | return key_exists($handler, $this->handlers); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param $handler |
||
46 | * @return null|HandlerConfig |
||
47 | */ |
||
48 | 1 | public function getHandlerConfig($handler) |
|
49 | { |
||
50 | 1 | return $this->handlers[$handler] ?? null; |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return FormatterConfig[] |
||
55 | */ |
||
56 | 2 | public function getFormatters() : array |
|
60 | |||
61 | 1 | public function hasFormatterConfig($formatter) : bool |
|
62 | { |
||
63 | 1 | return key_exists($formatter, $this->formatters); |
|
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param $formatter |
||
68 | * @return null|FormatterConfig |
||
69 | */ |
||
70 | 1 | public function getFormatterConfig($formatter) |
|
71 | { |
||
72 | 1 | return $this->formatters[$formatter] ?? null; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return FormatterConfig[] |
||
77 | */ |
||
78 | 2 | public function getProcessors() : array |
|
82 | |||
83 | 1 | public function hasProcessorConfig($processor) : bool |
|
84 | { |
||
85 | 1 | return key_exists($processor, $this->processors); |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param $processor |
||
90 | * @return null|ProcessorConfig |
||
91 | */ |
||
92 | 1 | public function getProcessorConfig($processor) |
|
93 | { |
||
94 | 1 | return $this->processors[$processor] ?? null; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return ChannelConfig[] |
||
99 | */ |
||
100 | 1 | public function getChannels() : array |
|
104 | |||
105 | /** |
||
106 | * @param $channel |
||
107 | * @return bool |
||
108 | */ |
||
109 | 1 | public function hasChannelConfig($channel) : bool |
|
110 | { |
||
111 | 1 | return key_exists($channel, $this->channels); |
|
112 | } |
||
113 | |||
114 | 1 | public function getChannelConfig($channel) |
|
115 | { |
||
116 | 1 | return $this->channels[$channel] ?? null; |
|
117 | } |
||
118 | |||
119 | 18 | protected function validateConfig($config) |
|
141 | |||
142 | 18 | protected function buildHandlers($config) |
|
148 | |||
149 | 18 | protected function buildChannels($config) |
|
155 | |||
156 | 18 | protected function buildFormatters($config) |
|
166 | |||
167 | 18 | protected function buildProcessors($config) |
|
177 | } |
||
178 |