current_scores[ $position ] = $current_score; } /** * Parses the current score list to the expected key value representation. * * @return array>> The score list presented as the expected key value representation. */ public function to_array(): array { $array = []; \ksort( $this->current_scores ); foreach ( $this->current_scores as $key => $current_score ) { $array[] = [ 'name' => $current_score->get_name(), 'amount' => $current_score->get_amount(), 'links' => $current_score->get_links_to_array(), ]; if ( $current_score->get_ids() !== null ) { $array[ $key ]['ids'] = $current_score->get_ids(); } } return $array; } }