ChainRequestMatcher.php 873 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation;
  11. /**
  12. * ChainRequestMatcher verifies that all checks match against a Request instance.
  13. *
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class ChainRequestMatcher implements RequestMatcherInterface
  17. {
  18. /**
  19. * @param iterable<RequestMatcherInterface> $matchers
  20. */
  21. public function __construct(private iterable $matchers)
  22. {
  23. }
  24. public function matches(Request $request): bool
  25. {
  26. foreach ($this->matchers as $matcher) {
  27. if (!$matcher->matches($request)) {
  28. return false;
  29. }
  30. }
  31. return true;
  32. }
  33. }