public static function promptByKey($text, array
$options,
$validation = null
): string
{ if (is_string($text)) { $text =
[$text];
} elseif (!
is_array($text)) { throw new InvalidArgumentException('$text can only be of type string|array'
);
} CLI::
isZeroOptions($options);
if ($line =
array_shift($text)) { CLI::
write($line);
} CLI::
printKeysAndValues($options);
return static::
prompt(PHP_EOL .
array_shift($text),
array_keys($options),
$validation);
} /**
* This method is the same as promptByKey(), but this method supports multiple keys, separated by commas.
*
* @param string $text Output "field" text or an one or two value array where the first value is the text before listing the options
* and the second value the text before asking to select one option. Provide empty string to omit
* @param array $options A list of options (array(key => description)), the first option will be the default value
*
* @return array The selected key(s) and value(s) of $options
*/