1 | <?php |
||
19 | class ServerRequestFactory implements ServerRequestFactoryInterface |
||
20 | { |
||
21 | 16 | public function createServerRequest($method, $uri): ServerRequestInterface |
|
25 | |||
26 | 7 | public function createServerRequestFromArray(array $server): ServerRequestInterface |
|
33 | |||
34 | /** |
||
35 | * Create a new server request from a set of arrays. |
||
36 | * |
||
37 | * @param array $server Typically $_SERVER or similar structure. |
||
38 | * @param array $headers Typically the output of getallheaders() or similar structure. |
||
39 | * @param array $cookie Typically $_COOKIE or similar structure. |
||
40 | * @param array $get Typically $_GET or similar structure. |
||
41 | * @param array $post Typically $_POST or similar structure. |
||
42 | * @param array $files Typically $_FILES or similar structure. |
||
43 | * |
||
44 | * @throws InvalidArgumentException If no valid method or URI can be determined. |
||
45 | * |
||
46 | * @return ServerRequestInterface |
||
47 | */ |
||
48 | public function createServerRequestFromArrays( |
||
69 | |||
70 | /** |
||
71 | * Create a new server request from the current environment variables. |
||
72 | * Defaults to a GET request to minimise the risk of an InvalidArgumentException. |
||
73 | * Includes the current request headers as supplied by the server through `getallheaders()`. |
||
74 | * |
||
75 | * @throws InvalidArgumentException If no valid method or URI can be determined. |
||
76 | * |
||
77 | * @return ServerRequestInterface |
||
78 | */ |
||
79 | public function createServerRequestFromGlobals(): ServerRequestInterface |
||
88 | |||
89 | 7 | private function getMethodFromEnvironment(array $environment): string |
|
96 | |||
97 | 7 | private function getUriFromEnvironmentWithHTTP(array $environment): \Psr\Http\Message\UriInterface |
|
105 | |||
106 | /** |
||
107 | * Return an UploadedFile instance array. |
||
108 | * |
||
109 | * @param array $files A array which respect $_FILES structure |
||
110 | * |
||
111 | * @throws InvalidArgumentException for unrecognized values |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | private static function normalizeFiles(array $files): array |
||
134 | |||
135 | /** |
||
136 | * Create and return an UploadedFile instance from a $_FILES specification. |
||
137 | * |
||
138 | * If the specification represents an array of values, this method will |
||
139 | * delegate to normalizeNestedFileSpec() and return that return value. |
||
140 | * |
||
141 | * @param array $value $_FILES struct |
||
142 | * |
||
143 | * @return array|UploadedFileInterface |
||
144 | */ |
||
145 | private static function createUploadedFileFromSpec(array $value) |
||
159 | |||
160 | /** |
||
161 | * Normalize an array of file specifications. |
||
162 | * |
||
163 | * Loops through all nested files and returns a normalized array of |
||
164 | * UploadedFileInterface instances. |
||
165 | * |
||
166 | * @param array $files |
||
167 | * |
||
168 | * @return UploadedFileInterface[] |
||
169 | */ |
||
170 | private static function normalizeNestedFileSpec(array $files = []): array |
||
187 | } |
||
188 |