| Total Complexity | 3 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | class Route_Collection extends Collection { |
||
| 20 | |||
| 21 | protected const ALLOWED_ROUTE_TYPES = array( Route::class, Route_Group::class ); |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Overwrite this method in any extended classes, to modify the inital data. |
||
| 25 | * |
||
| 26 | * @param array<int|string, mixed> $data |
||
| 27 | * @return array<int|string, mixed> |
||
| 28 | */ |
||
| 29 | protected function map_construct( array $data ): array { |
||
| 30 | return array_filter( |
||
| 31 | $data, |
||
| 32 | function ( $datum ): bool { |
||
| 33 | return in_array( |
||
| 34 | esc_attr( get_class( $datum ) ?: '' ), // phpcs:ignore Universal.Operators.DisallowShortTernary.Found |
||
| 35 | self::ALLOWED_ROUTE_TYPES, |
||
| 36 | true |
||
| 37 | ); |
||
| 38 | } |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Adds a route to the collection |
||
| 44 | * |
||
| 45 | * @param Route|Route_Group $route |
||
| 46 | * @return static |
||
| 47 | */ |
||
| 48 | public function add_route( $route ) { |
||
| 51 | } |
||
| 52 | } |
||
| 53 |