| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | class MenuEvent extends Event |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var iterable<MenuItemInterface> |
||
| 15 | */ |
||
| 16 | public iterable $items; |
||
| 17 | |||
| 18 | public function __construct(Closure $items) |
||
| 19 | { |
||
| 20 | /** @var iterable<MenuItemInterface> $result */ |
||
| 21 | $result = call_user_func($items); |
||
| 22 | $this->items = $result; |
||
| 23 | } |
||
| 24 | |||
| 25 | public function append(callable $callable): void |
||
| 30 | } |
||
| 31 | |||
| 32 | public function prepend(callable $callable): void |
||
| 33 | { |
||
| 34 | /** @var iterable<MenuItemInterface> $result */ |
||
| 35 | $result = call_user_func($callable); |
||
| 36 | $this->items = $this->append_iterators($result, $this->items); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param iterable<MenuItemInterface> ...$iterators |
||
| 41 | * @return iterable<MenuItemInterface> |
||
| 42 | */ |
||
| 43 | private function append_iterators(iterable ...$iterators): iterable |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 52 |