choose() public method

public choose ( array $items, string $text = 'Enter a number to choose an item:', mixed $default = null ) : mixed
$items array An associative array of choices.
$text string Some text to precede the choices.
$default mixed A default (as a key in $items).
return mixed The chosen item (as a key in $items).
 /**
  * @param string          $sshUrl
  * @param InputInterface  $input
  *
  * @return array|false
  */
 public function chooseDatabase($sshUrl, InputInterface $input)
 {
     $relationships = $this->getRelationships($sshUrl);
     // Filter to find database (mysql and pgsql) relationships.
     $relationships = array_filter($relationships, function (array $relationship) {
         foreach ($relationship as $key => $service) {
             if ($service['scheme'] === 'mysql' || $service['scheme'] === 'pgsql') {
                 return true;
             }
         }
         return false;
     });
     if (empty($relationships)) {
         $this->output->writeln('No databases found');
         return false;
     }
     $questionHelper = new QuestionHelper($input, $this->output);
     $choices = [];
     $separator = '.';
     foreach ($relationships as $name => $relationship) {
         $serviceCount = count($relationship);
         foreach ($relationship as $key => $service) {
             $choices[$name . $separator . $key] = $name . ($serviceCount > 1 ? '.' . $key : '');
         }
     }
     $choice = $questionHelper->choose($choices, 'Enter a number to choose a database:');
     list($name, $key) = explode($separator, $choice, 2);
     $database = $relationships[$name][$key];
     // Add metadata about the database.
     $database['_relationship_name'] = $name;
     $database['_relationship_key'] = $key;
     return $database;
 }