original_string: protected function get_selected_options($returntexts = true) {
  
          $method = 'getHtml';
          if ($returntexts === false) {
              $method = 'getValue';
          }
  
          // Is the select multiple?
          $multiple = $this->field->hasAttribute('multiple');
  
          $selectedoptions = array(); // To accumulate found selected options.
  
          // Driver returns the values as an array or as a string depending
          // on whether multiple options are selected or not.
          $values = $this->field->getValue();
          if (!is_array($values)) {
              $values = array($values);
          }
  
          // Get all the options in the select and extract their value/text pairs.
          $alloptions = $this->field->findAll('xpath', '//option');
          foreach ($alloptions as $option) {
              // Is it selected?
              if (in_array($option->getValue(), $values)) {
                  if ($multiple) {
                      // If the select is multiple, text commas must be encoded.
                      $selectedoptions[] = trim(str_replace(',', '\,', $option->{$method}()));
                  } else {
                      $selectedoptions[] = trim($option->{$method}());
                  }
              }
          }
  
          return implode(', ', $selectedoptions);
      }
code: protected function get_selected_options($returntexts = true) {
  
          $method = 'getHtml';
          if ($returntexts === false) {
              $method = 'getValue';
          }
  
          // Is the select multiple?
          $multiple = $this->field->hasAttribute('multiple');
  
          $selectedoptions = array(); // To accumulate found selected options.
  
          // Driver returns the values as an array or as a string depending
          // on whether multiple options are selected or not.
          $values = $this->field->getValue();
          if (!is_array($values)) {
              $values = array($values);
          }
  
          // Get all the options in the select and extract their value/text pairs.
          $alloptions = $this->field->findAll('xpath', '//option');
          foreach ($alloptions as $option) {
              // Is it selected?
              if (in_array($option->getValue(), $values)) {
                  if ($multiple) {
                      // If the select is multiple, text commas must be encoded.
                      $selectedoptions[] = trim(str_replace(',', '\,', $option->{$method}()));
                  } else {
                      $selectedoptions[] = trim($option->{$method}());
                  }
              }
          }
  
          return implode(', ', $selectedoptions);
      }
code_tokens: protected function get_selected_options ( $ returntexts = true ) { $ method = 'getHtml' ; if ( $ returntexts === false ) { $ method = 'getValue' ; } // Is the select multiple? $ multiple = $ this -> field -> hasAttribute ( 'multiple' ) ; $ selectedoptions = array ( ) ; // To accumulate found selected options. // Driver returns the values as an array or as a string depending // on whether multiple options are selected or not. $ values = $ this -> field -> getValue ( ) ; if ( ! is_array ( $ values ) ) { $ values = array ( $ values ) ; } // Get all the options in the select and extract their value/text pairs. $ alloptions = $ this -> field -> findAll ( 'xpath' , '//option' ) ; foreach ( $ alloptions as $ option ) { // Is it selected? if ( in_array ( $ option -> getValue ( ) , $ values ) ) { if ( $ multiple ) { // If the select is multiple, text commas must be encoded. $ selectedoptions [ ] = trim ( str_replace ( ',' , '\,' , $ option -> { $ method } ( ) ) ) ; } else { $ selectedoptions [ ] = trim ( $ option -> { $ method } ( ) ) ; } } } return implode ( ', ' , $ selectedoptions ) ; }
docstring: Returns the field selected values.
  
  Externalized from the common behat_form_field API method get_value() as
  matches() needs to check against both values and texts.
  
  @param bool $returntexts Returns the options texts or the options values.
  @return string
docstring_tokens: Returns the field selected values .