Ingen beskrivning

HttpException.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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\HttpKernel\Exception;
  11. /**
  12. * HttpException.
  13. *
  14. * @author Kris Wallsmith <kris@symfony.com>
  15. */
  16. class HttpException extends \RuntimeException implements HttpExceptionInterface
  17. {
  18. private $statusCode;
  19. private $headers;
  20. public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0)
  21. {
  22. $this->statusCode = $statusCode;
  23. $this->headers = $headers;
  24. parent::__construct($message, $code, $previous);
  25. }
  26. public function getStatusCode()
  27. {
  28. return $this->statusCode;
  29. }
  30. public function getHeaders()
  31. {
  32. return $this->headers;
  33. }
  34. /**
  35. * Set response headers.
  36. *
  37. * @param array $headers Response headers
  38. */
  39. public function setHeaders(array $headers)
  40. {
  41. $this->headers = $headers;
  42. }
  43. }