Consonant.php 665 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /*
  3. * Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
  4. * SPDX-License-Identifier: MIT
  5. */
  6. declare(strict_types=1);
  7. namespace Respect\Validation\Rules;
  8. use function preg_match;
  9. /**
  10. * Validates if the input contains only consonants.
  11. *
  12. * @author Danilo Correa <danilosilva87@gmail.com>
  13. * @author Henrique Moody <henriquemoody@gmail.com>
  14. * @author Nick Lombard <github@jigsoft.co.za>
  15. */
  16. final class Consonant extends AbstractFilterRule
  17. {
  18. /**
  19. * {@inheritDoc}
  20. */
  21. protected function validateFilteredInput(string $input): bool
  22. {
  23. return preg_match('/^(\s|[b-df-hj-np-tv-zB-DF-HJ-NP-TV-Z])*$/', $input) > 0;
  24. }
  25. }