MethodNotAllowedException.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Routing\Exception;
  11. /**
  12. * The resource was found but the request method is not allowed.
  13. *
  14. * This exception should trigger an HTTP 405 response in your application code.
  15. *
  16. * @author Kris Wallsmith <kris@symfony.com>
  17. */
  18. class MethodNotAllowedException extends \RuntimeException implements ExceptionInterface
  19. {
  20. protected $allowedMethods = [];
  21. public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null)
  22. {
  23. $this->allowedMethods = array_map('strtoupper', $allowedMethods);
  24. parent::__construct($message, $code, $previous);
  25. }
  26. /**
  27. * Gets the allowed HTTP methods.
  28. *
  29. * @return array
  30. */
  31. public function getAllowedMethods()
  32. {
  33. return $this->allowedMethods;
  34. }
  35. }