ServerRequest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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()
  42. {
  43. return $this->requestTarget;
  44. }
  45. public function withRequestTarget($requestTarget)
  46. {
  47. throw new \BadMethodCallException('Not implemented.');
  48. }
  49. public function getMethod()
  50. {
  51. return $this->method;
  52. }
  53. public function withMethod($method)
  54. {
  55. }
  56. public function getUri()
  57. {
  58. return $this->uri;
  59. }
  60. public function withUri(UriInterface $uri, $preserveHost = false)
  61. {
  62. throw new \BadMethodCallException('Not implemented.');
  63. }
  64. public function getServerParams()
  65. {
  66. return $this->server;
  67. }
  68. public function getCookieParams()
  69. {
  70. return $this->cookies;
  71. }
  72. public function withCookieParams(array $cookies)
  73. {
  74. throw new \BadMethodCallException('Not implemented.');
  75. }
  76. public function getQueryParams()
  77. {
  78. return $this->query;
  79. }
  80. public function withQueryParams(array $query)
  81. {
  82. throw new \BadMethodCallException('Not implemented.');
  83. }
  84. public function getUploadedFiles()
  85. {
  86. return $this->uploadedFiles;
  87. }
  88. public function withUploadedFiles(array $uploadedFiles)
  89. {
  90. throw new \BadMethodCallException('Not implemented.');
  91. }
  92. public function getParsedBody()
  93. {
  94. return $this->data;
  95. }
  96. public function withParsedBody($data)
  97. {
  98. throw new \BadMethodCallException('Not implemented.');
  99. }
  100. public function getAttributes()
  101. {
  102. return $this->attributes;
  103. }
  104. public function getAttribute($name, $default = null)
  105. {
  106. return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
  107. }
  108. public function withAttribute($name, $value)
  109. {
  110. throw new \BadMethodCallException('Not implemented.');
  111. }
  112. public function withoutAttribute($name)
  113. {
  114. throw new \BadMethodCallException('Not implemented.');
  115. }
  116. }