original_string: public function menu($items, $default = null, $title = 'Choose an item')
      {
          if (isset($items[$default]) && strpos($title, '[') === false) {
              $title .= ' [default: ' . $items[$default] . ']';
          }
  
          $this->line(sprintf('%s: ', $title));
  
          $i = 1;
          $keys = array();
  
          foreach ($items as $key => $item) {
              $keys[$i] = $key;
              $this->line(sprintf('  %d. %s', $i, $item));
              $i++;
          }
  
          $selected = $this->in();
  
          if ($selected === '') {
              return $default;
          }
  
          if (isset($keys[$selected])) {
              return $keys[$selected];
          }
  
          return $selected;
      }
code: public function menu($items, $default = null, $title = 'Choose an item')
      {
          if (isset($items[$default]) && strpos($title, '[') === false) {
              $title .= ' [default: ' . $items[$default] . ']';
          }
  
          $this->line(sprintf('%s: ', $title));
  
          $i = 1;
          $keys = array();
  
          foreach ($items as $key => $item) {
              $keys[$i] = $key;
              $this->line(sprintf('  %d. %s', $i, $item));
              $i++;
          }
  
          $selected = $this->in();
  
          if ($selected === '') {
              return $default;
          }
  
          if (isset($keys[$selected])) {
              return $keys[$selected];
          }
  
          return $selected;
      }
code_tokens: public function menu ( $ items , $ default = null , $ title = 'Choose an item' ) { if ( isset ( $ items [ $ default ] ) && strpos ( $ title , '[' ) === false ) { $ title .= ' [default: ' . $ items [ $ default ] . ']' ; } $ this -> line ( sprintf ( '%s: ' , $ title ) ) ; $ i = 1 ; $ keys = array ( ) ; foreach ( $ items as $ key => $ item ) { $ keys [ $ i ] = $ key ; $ this -> line ( sprintf ( '  %d. %s' , $ i , $ item ) ) ; $ i ++ ; } $ selected = $ this -> in ( ) ; if ( $ selected === '' ) { return $ default ; } if ( isset ( $ keys [ $ selected ] ) ) { return $ keys [ $ selected ] ; } return $ selected ; }
docstring: Displays a menu where a user can enter a number to choose an option
  @param array $items An array like array('key' => 'Label')
  @param mixed $default
  @param string $title
  @return mixed
docstring_tokens: Displays a menu where a user can enter a number to choose an option