BaseFactory.php
30 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\TableScreen\TableRowsFactory; |
| 6 | |
| 7 | use AC\TableScreen; |
| 8 | use AC\TableScreen\TableRows; |
| 9 | use AC\TableScreen\TableRowsFactory; |
| 10 | |
| 11 | class BaseFactory implements TableRowsFactory |
| 12 | { |
| 13 | |
| 14 | public function create(TableScreen $table_screen): ?TableRows |
| 15 | { |
| 16 | switch (true) { |
| 17 | case $table_screen instanceof TableScreen\Post : |
| 18 | return new TableScreen\TableRows\Post($table_screen); |
| 19 | case $table_screen instanceof TableScreen\Media : |
| 20 | return new TableScreen\TableRows\Media($table_screen); |
| 21 | case $table_screen instanceof TableScreen\Comment : |
| 22 | return new TableScreen\TableRows\Comment($table_screen); |
| 23 | case $table_screen instanceof TableScreen\User : |
| 24 | return new TableScreen\TableRows\User($table_screen); |
| 25 | default: |
| 26 | return null; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | } |