$items The trail. * @return array|null Null when the trail is too short. */ public static function build( Node_Context $c, array $items ): ?array { $items = array_values( array_filter( $items, static function ( $item ) { return is_array( $item ) && '' !== trim( (string) ( $item['title'] ?? '' ) ); } ) ); if ( count( $items ) < 2 ) { return null; } $elements = array(); $last = count( $items ) - 1; foreach ( $items as $index => $item ) { $elements[] = array( '@type' => 'ListItem', 'position' => $index + 1, 'name' => trim( (string) $item['title'] ), 'item' => $index === $last ? null : $item['url'], ); } return array( '@type' => 'BreadcrumbList', '@id' => $c->id( 'breadcrumb' ), 'itemListElement' => $elements, ); } }