original_string: protected function filterOptionsBySearch($options, $query)
      {
          $filteredOptions = [];
  
          $optionMatchesSearch = function ($words, $option) {
              foreach ($words as $word) {
                  $word = trim($word);
                  if (!strlen($word)) {
                      continue;
                  }
  
                  if (!Str::contains(Str::lower($option), $word)) {
                      return false;
                  }
              }
  
              return true;
          };
  
          /*
           * Exact
           */
          foreach ($options as $index => $option) {
              if (Str::is(Str::lower($option), $query)) {
                  $filteredOptions[$index] = $option;
                  unset($options[$index]);
              }
          }
  
          /*
           * Fuzzy
           */
          $words = explode(' ', $query);
          foreach ($options as $index => $option) {
              if ($optionMatchesSearch($words, $option)) {
                  $filteredOptions[$index] = $option;
              }
          }
  
          return $filteredOptions;
      }
code: protected function filterOptionsBySearch($options, $query)
      {
          $filteredOptions = [];
  
          $optionMatchesSearch = function ($words, $option) {
              foreach ($words as $word) {
                  $word = trim($word);
                  if (!strlen($word)) {
                      continue;
                  }
  
                  if (!Str::contains(Str::lower($option), $word)) {
                      return false;
                  }
              }
  
              return true;
          };
  
          /*
           * Exact
           */
          foreach ($options as $index => $option) {
              if (Str::is(Str::lower($option), $query)) {
                  $filteredOptions[$index] = $option;
                  unset($options[$index]);
              }
          }
  
          /*
           * Fuzzy
           */
          $words = explode(' ', $query);
          foreach ($options as $index => $option) {
              if ($optionMatchesSearch($words, $option)) {
                  $filteredOptions[$index] = $option;
              }
          }
  
          return $filteredOptions;
      }
code_tokens: protected function filterOptionsBySearch ( $ options , $ query ) { $ filteredOptions = [ ] ; $ optionMatchesSearch = function ( $ words , $ option ) { foreach ( $ words as $ word ) { $ word = trim ( $ word ) ; if ( ! strlen ( $ word ) ) { continue ; } if ( ! Str :: contains ( Str :: lower ( $ option ) , $ word ) ) { return false ; } } return true ; } ; /*
           * Exact
           */ foreach ( $ options as $ index => $ option ) { if ( Str :: is ( Str :: lower ( $ option ) , $ query ) ) { $ filteredOptions [ $ index ] = $ option ; unset ( $ options [ $ index ] ) ; } } /*
           * Fuzzy
           */ $ words = explode ( ' ' , $ query ) ; foreach ( $ options as $ index => $ option ) { if ( $ optionMatchesSearch ( $ words , $ option ) ) { $ filteredOptions [ $ index ] = $ option ; } } return $ filteredOptions ; }
docstring: Filters an array of options by a search term.
  @param array $options
  @param string $query
  @return array
docstring_tokens: Filters an array of options by a search term .