0
0

ServerRequest.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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\Bridge\PsrHttpMessage\Tests\Fixtures;
  11. use Psr\Http\Message\ServerRequestInterface;
  12. use Psr\Http\Message\StreamInterface;
  13. use Psr\Http\Message\UriInterface;
  14. /**
  15. * @author Kévin Dunglas <dunglas@gmail.com>
  16. */
  17. class ServerRequest extends Message implements ServerRequestInterface
  18. {
  19. private $requestTarget;
  20. private $method;
  21. private $uri;
  22. private $server;
  23. private $cookies;
  24. private $query;
  25. private $uploadedFiles;
  26. private $data;
  27. private $attributes;
  28. public function __construct($version = '1.1', array $headers = [], StreamInterface $body = null, $requestTarget = '/', $method = 'GET', $uri = null, array $server = [], array $cookies = [], array $query = [], array $uploadedFiles = [], $data = null, array $attributes = [])
  29. {
  30. parent::__construct($version, $headers, $body);
  31. $this->requestTarget = $requestTarget;
  32. $this->method = $method;
  33. $this->uri = $uri;
  34. $this->server = $server;
  35. $this->cookies = $cookies;
  36. $this->query = $query;
  37. $this->uploadedFiles = $uploadedFiles;
  38. $this->data = $data;
  39. $this->attributes = $attributes;
  40. }
  41. public function getRequestTarget(): string
  42. {
  43. return $this->requestTarget;
  44. }
  45. /**
  46. * {@inheritdoc}
  47. *
  48. * @return static
  49. */
  50. public function withRequestTarget($requestTarget)
  51. {
  52. throw new \BadMethodCallException('Not implemented.');
  53. }
  54. public function getMethod(): string
  55. {
  56. return $this->method;
  57. }
  58. /**
  59. * {@inheritdoc}
  60. *
  61. * @return static
  62. */
  63. public function withMethod($method)
  64. {
  65. throw new \BadMethodCallException('Not implemented.');
  66. }
  67. /**
  68. * {@inheritdoc}
  69. *
  70. * @return UriInterface
  71. */
  72. public function getUri()
  73. {
  74. return $this->uri;
  75. }
  76. /**
  77. * {@inheritdoc}
  78. *
  79. * @return static
  80. */
  81. public function withUri(UriInterface $uri, $preserveHost = false)
  82. {
  83. throw new \BadMethodCallException('Not implemented.');
  84. }
  85. public function getServerParams(): array
  86. {
  87. return $this->server;
  88. }
  89. public function getCookieParams(): array
  90. {
  91. return $this->cookies;
  92. }
  93. /**
  94. * {@inheritdoc}
  95. *
  96. * @return static
  97. */
  98. public function withCookieParams(array $cookies)
  99. {
  100. throw new \BadMethodCallException('Not implemented.');
  101. }
  102. public function getQueryParams(): array
  103. {
  104. return $this->query;
  105. }
  106. /**
  107. * {@inheritdoc}
  108. *
  109. * @return static
  110. */
  111. public function withQueryParams(array $query)
  112. {
  113. throw new \BadMethodCallException('Not implemented.');
  114. }
  115. public function getUploadedFiles(): array
  116. {
  117. return $this->uploadedFiles;
  118. }
  119. /**
  120. * {@inheritdoc}
  121. *
  122. * @return static
  123. */
  124. public function withUploadedFiles(array $uploadedFiles)
  125. {
  126. throw new \BadMethodCallException('Not implemented.');
  127. }
  128. /**
  129. * {@inheritdoc}
  130. *
  131. * @return array|object|null
  132. */
  133. public function getParsedBody()
  134. {
  135. return $this->data;
  136. }
  137. /**
  138. * {@inheritdoc}
  139. *
  140. * @return static
  141. */
  142. public function withParsedBody($data)
  143. {
  144. throw new \BadMethodCallException('Not implemented.');
  145. }
  146. public function getAttributes(): array
  147. {
  148. return $this->attributes;
  149. }
  150. /**
  151. * {@inheritdoc}
  152. *
  153. * @return mixed
  154. */
  155. public function getAttribute($name, $default = null)
  156. {
  157. return $this->attributes[$name] ?? $default;
  158. }
  159. /**
  160. * {@inheritdoc}
  161. *
  162. * @return static
  163. */
  164. public function withAttribute($name, $value)
  165. {
  166. throw new \BadMethodCallException('Not implemented.');
  167. }
  168. /**
  169. * {@inheritdoc}
  170. *
  171. * @return static
  172. */
  173. public function withoutAttribute($name)
  174. {
  175. throw new \BadMethodCallException('Not implemented.');
  176. }
  177. }