@@ -13,83 +13,83 @@ |
||
13 | 13 | |
14 | 14 | class ServerRequest extends Request implements ServerRequestInterface, ServerMessageInterface |
15 | 15 | { |
16 | - use ServerMessage; |
|
17 | - |
|
18 | - protected array $cookieParams = []; |
|
19 | - |
|
20 | - /** @var array|object|null */ |
|
21 | - protected $parsedBody; |
|
22 | - protected array $queryParams = []; |
|
23 | - protected array $serverParams; |
|
24 | - |
|
25 | - /** @var UploadedFileInterface[] */ |
|
26 | - protected array $uploadedFiles = []; |
|
27 | - |
|
28 | - |
|
29 | - public function __construct( |
|
30 | - string $method, |
|
31 | - UriInterface $uri, |
|
32 | - array $headers = [], |
|
33 | - $body = null, |
|
34 | - string $version = '1.1', |
|
35 | - array $serverParams = [] |
|
36 | - ) { |
|
37 | - parent::__construct($method, $uri, $headers, $body, $version); |
|
38 | - |
|
39 | - $this->serverParams = $serverParams; |
|
40 | - parse_str($uri->getQuery(), $this->queryParams); |
|
41 | - } |
|
42 | - |
|
43 | - public function getServerParams(): array |
|
44 | - { |
|
45 | - return $this->serverParams; |
|
46 | - } |
|
47 | - |
|
48 | - public function getUploadedFiles(): array |
|
49 | - { |
|
50 | - return $this->uploadedFiles; |
|
51 | - } |
|
52 | - |
|
53 | - public function withUploadedFiles(array $uploadedFiles) |
|
54 | - { |
|
55 | - $this->uploadedFiles = $uploadedFiles; |
|
56 | - return $this; |
|
57 | - } |
|
58 | - |
|
59 | - public function getCookieParams(): array |
|
60 | - { |
|
61 | - return $this->cookieParams; |
|
62 | - } |
|
63 | - |
|
64 | - public function withCookieParams(array $cookies) |
|
65 | - { |
|
66 | - $this->cookieParams = $cookies; |
|
67 | - return $this; |
|
68 | - } |
|
69 | - |
|
70 | - public function getQueryParams(): array |
|
71 | - { |
|
72 | - return $this->queryParams; |
|
73 | - } |
|
74 | - |
|
75 | - public function withQueryParams(array $query) |
|
76 | - { |
|
77 | - $this->queryParams = $query; |
|
78 | - return $this; |
|
79 | - } |
|
80 | - |
|
81 | - public function getParsedBody() |
|
82 | - { |
|
83 | - return $this->parsedBody; |
|
84 | - } |
|
85 | - |
|
86 | - public function withParsedBody($data) |
|
87 | - { |
|
88 | - if (!is_array($data) && !is_object($data) && null !== $data) { |
|
89 | - throw new InvalidArgumentException('First parameter to withParsedBody MUST be object, array or null'); |
|
90 | - } |
|
91 | - |
|
92 | - $this->parsedBody = $data; |
|
93 | - return $this; |
|
94 | - } |
|
16 | + use ServerMessage; |
|
17 | + |
|
18 | + protected array $cookieParams = []; |
|
19 | + |
|
20 | + /** @var array|object|null */ |
|
21 | + protected $parsedBody; |
|
22 | + protected array $queryParams = []; |
|
23 | + protected array $serverParams; |
|
24 | + |
|
25 | + /** @var UploadedFileInterface[] */ |
|
26 | + protected array $uploadedFiles = []; |
|
27 | + |
|
28 | + |
|
29 | + public function __construct( |
|
30 | + string $method, |
|
31 | + UriInterface $uri, |
|
32 | + array $headers = [], |
|
33 | + $body = null, |
|
34 | + string $version = '1.1', |
|
35 | + array $serverParams = [] |
|
36 | + ) { |
|
37 | + parent::__construct($method, $uri, $headers, $body, $version); |
|
38 | + |
|
39 | + $this->serverParams = $serverParams; |
|
40 | + parse_str($uri->getQuery(), $this->queryParams); |
|
41 | + } |
|
42 | + |
|
43 | + public function getServerParams(): array |
|
44 | + { |
|
45 | + return $this->serverParams; |
|
46 | + } |
|
47 | + |
|
48 | + public function getUploadedFiles(): array |
|
49 | + { |
|
50 | + return $this->uploadedFiles; |
|
51 | + } |
|
52 | + |
|
53 | + public function withUploadedFiles(array $uploadedFiles) |
|
54 | + { |
|
55 | + $this->uploadedFiles = $uploadedFiles; |
|
56 | + return $this; |
|
57 | + } |
|
58 | + |
|
59 | + public function getCookieParams(): array |
|
60 | + { |
|
61 | + return $this->cookieParams; |
|
62 | + } |
|
63 | + |
|
64 | + public function withCookieParams(array $cookies) |
|
65 | + { |
|
66 | + $this->cookieParams = $cookies; |
|
67 | + return $this; |
|
68 | + } |
|
69 | + |
|
70 | + public function getQueryParams(): array |
|
71 | + { |
|
72 | + return $this->queryParams; |
|
73 | + } |
|
74 | + |
|
75 | + public function withQueryParams(array $query) |
|
76 | + { |
|
77 | + $this->queryParams = $query; |
|
78 | + return $this; |
|
79 | + } |
|
80 | + |
|
81 | + public function getParsedBody() |
|
82 | + { |
|
83 | + return $this->parsedBody; |
|
84 | + } |
|
85 | + |
|
86 | + public function withParsedBody($data) |
|
87 | + { |
|
88 | + if (!is_array($data) && !is_object($data) && null !== $data) { |
|
89 | + throw new InvalidArgumentException('First parameter to withParsedBody MUST be object, array or null'); |
|
90 | + } |
|
91 | + |
|
92 | + $this->parsedBody = $data; |
|
93 | + return $this; |
|
94 | + } |
|
95 | 95 | } |