original_string: public function getOptionByValue($value)
      {
          // walk all options
          foreach ($this->options as $option) {
              if ($option instanceof Option) {
                  if ($option->getValue() == $value) {
                      return $option;
                  }
              } else {
                  if ($option instanceof Optgroup) {
                      $options = $option->getOptions();
                      foreach ($options as $option2) {
                          if ($option2->getValue() == $value) {
                              return $option2;
                          }
                      }
                  }
              }
          }
  
          return null;
      }
code: public function getOptionByValue($value)
      {
          // walk all options
          foreach ($this->options as $option) {
              if ($option instanceof Option) {
                  if ($option->getValue() == $value) {
                      return $option;
                  }
              } else {
                  if ($option instanceof Optgroup) {
                      $options = $option->getOptions();
                      foreach ($options as $option2) {
                          if ($option2->getValue() == $value) {
                              return $option2;
                          }
                      }
                  }
              }
          }
  
          return null;
      }
code_tokens: public function getOptionByValue ( $ value ) { // walk all options foreach ( $ this -> options as $ option ) { if ( $ option instanceof Option ) { if ( $ option -> getValue ( ) == $ value ) { return $ option ; } } else { if ( $ option instanceof Optgroup ) { $ options = $ option -> getOptions ( ) ; foreach ( $ options as $ option2 ) { if ( $ option2 -> getValue ( ) == $ value ) { return $ option2 ; } } } } } return null ; }
docstring: Return the option which has the given value.
  If there are multiple options with the same value, the first will be returned.
  
  @param $value
  @return Option
docstring_tokens: Return the option which has the given value . If there are multiple options with the same value the first will be returned .