1 | <?php |
||
9 | class HandlerConfig extends ParametrizedObjectConfig |
||
10 | { |
||
11 | public const PROCESSORS = 'processors'; |
||
12 | public const FORMATTER = 'formatter'; |
||
13 | |||
14 | /** @var callable[]|ProcessorConfig[] */ |
||
15 | protected $processors; |
||
16 | |||
17 | /** @var FormatterInterface|FormatterConfig|null */ |
||
18 | protected $formatter; |
||
19 | |||
20 | 13 | protected function __construct( |
|
30 | |||
31 | 14 | public static function fromArray(array $config) |
|
32 | { |
||
33 | 14 | $config = self::filter($config); |
|
34 | |||
35 | 13 | return new static( |
|
36 | 13 | $config[self::NAME], |
|
37 | 13 | $config[self::PARAMETERS], |
|
38 | array_map(function ($processor) { |
||
39 | 1 | return is_array($processor) ? ProcessorConfig::fromArray($processor) : $processor; |
|
40 | 13 | }, $config[self::PROCESSORS]), |
|
41 | 13 | is_array($config[self::FORMATTER]) |
|
42 | 2 | ? FormatterConfig::fromArray($config[self::FORMATTER]) |
|
43 | 13 | : $config[self::FORMATTER] |
|
44 | ); |
||
45 | } |
||
46 | |||
47 | 14 | protected static function defaults(): array |
|
54 | |||
55 | 14 | protected static function validate(array $config): void |
|
62 | |||
63 | 13 | public function getProcessors(): array |
|
67 | |||
68 | 13 | public function getFormatter() |
|
72 | } |
||
73 |