original_string: public function set_type_toggle($options = null) {
          if ($options === null) {
              $options = array(0, 1);
          }
          $options = array_values($options);
          $idx = array_search($this->value, $options, true);
          if ($idx === false) {
              throw new \coding_exception('Specified value must be one of the toggle options');
          }
          $nextvalue = ($idx < count($options) - 1) ? $idx + 1 : 0;
  
          $this->type = 'toggle';
          $this->options = (string)$nextvalue;
          return $this;
      }
code: public function set_type_toggle($options = null) {
          if ($options === null) {
              $options = array(0, 1);
          }
          $options = array_values($options);
          $idx = array_search($this->value, $options, true);
          if ($idx === false) {
              throw new \coding_exception('Specified value must be one of the toggle options');
          }
          $nextvalue = ($idx < count($options) - 1) ? $idx + 1 : 0;
  
          $this->type = 'toggle';
          $this->options = (string)$nextvalue;
          return $this;
      }
code_tokens: public function set_type_toggle ( $ options = null ) { if ( $ options === null ) { $ options = array ( 0 , 1 ) ; } $ options = array_values ( $ options ) ; $ idx = array_search ( $ this -> value , $ options , true ) ; if ( $ idx === false ) { throw new \ coding_exception ( 'Specified value must be one of the toggle options' ) ; } $ nextvalue = ( $ idx < count ( $ options ) - 1 ) ? $ idx + 1 : 0 ; $ this -> type = 'toggle' ; $ this -> options = ( string ) $ nextvalue ; return $ this ; }
docstring: Sets the element type to be a toggle
  
  For toggle element $editlabel is not used.
  $displayvalue must be specified, it can have text or icons but can not contain html links.
  
  Toggle element can have two or more options.
  
  @param array $options toggle options as simple, non-associative array; defaults to array(0,1)
  @return self
docstring_tokens: Sets the element type to be a toggle