Request.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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\BrowserKit;
  11. /**
  12. * @author Fabien Potencier <fabien@symfony.com>
  13. */
  14. class Request
  15. {
  16. protected $uri;
  17. protected $method;
  18. protected $parameters;
  19. protected $files;
  20. protected $cookies;
  21. protected $server;
  22. protected $content;
  23. /**
  24. * @param string $uri The request URI
  25. * @param string $method The HTTP method request
  26. * @param array $parameters The request parameters
  27. * @param array $files An array of uploaded files
  28. * @param array $cookies An array of cookies
  29. * @param array $server An array of server parameters
  30. * @param string $content The raw body data
  31. */
  32. public function __construct(string $uri, string $method, array $parameters = [], array $files = [], array $cookies = [], array $server = [], string $content = null)
  33. {
  34. $this->uri = $uri;
  35. $this->method = $method;
  36. array_walk_recursive($parameters, static function (&$value) {
  37. $value = (string) $value;
  38. });
  39. $this->parameters = $parameters;
  40. $this->files = $files;
  41. $this->cookies = $cookies;
  42. $this->server = $server;
  43. $this->content = $content;
  44. }
  45. /**
  46. * Gets the request URI.
  47. *
  48. * @return string The request URI
  49. */
  50. public function getUri()
  51. {
  52. return $this->uri;
  53. }
  54. /**
  55. * Gets the request HTTP method.
  56. *
  57. * @return string The request HTTP method
  58. */
  59. public function getMethod()
  60. {
  61. return $this->method;
  62. }
  63. /**
  64. * Gets the request parameters.
  65. *
  66. * @return array The request parameters
  67. */
  68. public function getParameters()
  69. {
  70. return $this->parameters;
  71. }
  72. /**
  73. * Gets the request server files.
  74. *
  75. * @return array The request files
  76. */
  77. public function getFiles()
  78. {
  79. return $this->files;
  80. }
  81. /**
  82. * Gets the request cookies.
  83. *
  84. * @return array The request cookies
  85. */
  86. public function getCookies()
  87. {
  88. return $this->cookies;
  89. }
  90. /**
  91. * Gets the request server parameters.
  92. *
  93. * @return array The request server parameters
  94. */
  95. public function getServer()
  96. {
  97. return $this->server;
  98. }
  99. /**
  100. * Gets the request raw body data.
  101. *
  102. * @return string|null The request raw body data
  103. */
  104. public function getContent()
  105. {
  106. return $this->content;
  107. }
  108. }