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.

27 lines
588 B

  1. <?php namespace TomLingham\Searchy\Matchers;
  2. /**
  3. * Matches the start of each word against each word in a search
  4. *
  5. * For example, a search for 'jo ta' would match; 'John Taylor' or 'Joshua B. Takashi'
  6. *
  7. * Class StartOfWordsMatcher
  8. * @package TomLingham\Searchy\Matchers
  9. */
  10. class StartOfWordsMatcher extends BaseMatcher
  11. {
  12. /**
  13. * @var string
  14. */
  15. protected $operator = 'LIKE';
  16. /**
  17. * @param $searchString
  18. * @return string
  19. */
  20. public function formatSearchString( $searchString )
  21. {
  22. return implode('% ', explode(' ', $searchString)) . '%';
  23. }
  24. }