Digit.php 618 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 ctype_digit;
  9. /**
  10. * Validates whether the input contains only digits.
  11. *
  12. * @author Alexandre Gomes Gaigalas <alganet@gmail.com>
  13. * @author Henrique Moody <henriquemoody@gmail.com>
  14. * @author Nick Lombard <github@jigsoft.co.za>
  15. */
  16. final class Digit extends AbstractFilterRule
  17. {
  18. /**
  19. * {@inheritDoc}
  20. */
  21. protected function validateFilteredInput(string $input): bool
  22. {
  23. return ctype_digit($input);
  24. }
  25. }