You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
684 B

  1. <?php
  2. namespace TomLingham\Searchy\Matchers;
  3. /**
  4. * Matches strings for Acronym 'like' matches but does NOT return Studly Case Matches.
  5. *
  6. * for example, a search for 'fb' would match; 'foo bar' or 'Fred Brown' but not 'FreeBeer'.
  7. *
  8. * Class AcronymMatcher
  9. */
  10. class AcronymUnicodeMatcher extends BaseMatcher
  11. {
  12. /**
  13. * @var string
  14. */
  15. protected $operator = 'LIKE';
  16. /**
  17. * @param $searchString
  18. *
  19. * @return mixed|string
  20. */
  21. public function formatSearchString($searchString)
  22. {
  23. $results = [];
  24. preg_match_all('/./u', mb_strtoupper($searchString, 'UTF-8'), $results);
  25. return implode('% ', $results[0]).'%';
  26. }
  27. }