Negative.php 656 B

12345678910111213141516171819202122232425262728293031323334
  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 is_numeric;
  9. /**
  10. * Validates whether the input is a negative number.
  11. *
  12. * @author Alexandre Gomes Gaigalas <alganet@gmail.com>
  13. * @author Henrique Moody <henriquemoody@gmail.com>
  14. * @author Ismael Elias <ismael.esq@hotmail.com>
  15. */
  16. final class Negative extends AbstractRule
  17. {
  18. /**
  19. * {@inheritDoc}
  20. */
  21. public function validate($input): bool
  22. {
  23. if (!is_numeric($input)) {
  24. return false;
  25. }
  26. return $input < 0;
  27. }
  28. }