Total Complexity | 7 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class CombinedReducer |
||
14 | { |
||
15 | /** |
||
16 | * @var array<string,callable> |
||
17 | */ |
||
18 | protected $reducers = []; |
||
19 | |||
20 | /** |
||
21 | * CombinedReducer constructor. |
||
22 | * |
||
23 | * @param array<string,callable> $reducers |
||
24 | */ |
||
25 | 1 | public function __construct(array $reducers) |
|
26 | { |
||
27 | 1 | foreach ($reducers as $key => $reducer) { |
|
28 | 1 | $this->addReducer($key, $reducer); |
|
29 | } |
||
30 | 1 | } |
|
31 | |||
32 | /** |
||
33 | * @param array $state |
||
34 | * @param ActionInterface $action |
||
35 | * @return array |
||
36 | */ |
||
37 | 1 | public function __invoke(array $state, ActionInterface $action): array |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param callable $reducer |
||
51 | */ |
||
52 | 1 | protected function addReducer(string $key, callable $reducer): void |
|
53 | { |
||
54 | 1 | $this->reducers[$key] = $reducer; |
|
55 | 1 | } |
|
56 | |||
57 | /** |
||
58 | * @return array<string,callable> |
||
59 | */ |
||
60 | 1 | protected function getReducers(): array |
|
63 | } |
||
64 | } |