ColumnFactories.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Collection; |
| 6 | |
| 7 | use AC\Collection; |
| 8 | use AC\Column\ColumnFactory; |
| 9 | |
| 10 | class ColumnFactories extends Collection |
| 11 | { |
| 12 | |
| 13 | public function __construct(array $factories = []) |
| 14 | { |
| 15 | array_map([$this, 'add'], $factories); |
| 16 | } |
| 17 | |
| 18 | public function add(ColumnFactory $factory): void |
| 19 | { |
| 20 | $this->data[$factory->get_column_type()] = $factory; |
| 21 | } |
| 22 | |
| 23 | public function current(): ColumnFactory |
| 24 | { |
| 25 | return current($this->data); |
| 26 | } |
| 27 | } |