No.php 626 B

1234567891011121314151617181920212223242526272829303132
  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 nl_langinfo;
  9. use const NOEXPR;
  10. /**
  11. * Validates if value is considered as "No".
  12. *
  13. * @author Henrique Moody <henriquemoody@gmail.com>
  14. */
  15. final class No extends AbstractEnvelope
  16. {
  17. public function __construct(bool $useLocale = false)
  18. {
  19. $pattern = '^n(o(t|pe)?|ix|ay)?$';
  20. if ($useLocale) {
  21. $pattern = nl_langinfo(NOEXPR);
  22. }
  23. parent::__construct(new Regex('/' . $pattern . '/i'));
  24. }
  25. }