1 | <?php |
||
18 | class ServerRequestFactory implements ServerRequestFactoryInterface |
||
19 | { |
||
20 | 16 | public function createServerRequest($method, $uri): ServerRequestInterface |
|
24 | |||
25 | 7 | public function createServerRequestFromArray(array $server): ServerRequestInterface |
|
36 | |||
37 | /** |
||
38 | * Create a new server request from a set of arrays. |
||
39 | * |
||
40 | * @param array $server Typically $_SERVER or similar structure. |
||
41 | * @param array $headers Typically the output of getallheaders() or similar structure. |
||
42 | * @param array $cookie Typically $_COOKIE or similar structure. |
||
43 | * @param array $get Typically $_GET or similar structure. |
||
44 | * @param array $post Typically $_POST or similar structure. |
||
45 | * @param array $files Typically $_FILES or similar structure. |
||
46 | * |
||
47 | * @throws InvalidArgumentException If no valid method or URI can be determined. |
||
48 | * |
||
49 | * @return ServerRequestInterface |
||
50 | */ |
||
51 | public function createServerRequestFromArrays( |
||
72 | |||
73 | /** |
||
74 | * Create a new server request from the current environment variables. |
||
75 | * Defaults to a GET request to minimise the risk of an InvalidArgumentException. |
||
76 | * Includes the current request headers as supplied by the server through `getallheaders()`. |
||
77 | * |
||
78 | * @throws InvalidArgumentException If no valid method or URI can be determined. |
||
79 | * |
||
80 | * @return ServerRequestInterface |
||
81 | */ |
||
82 | public function createServerRequestFromGlobals(): ServerRequestInterface |
||
92 | |||
93 | 7 | private function getMethodFromEnvironment(array $environment): string |
|
101 | |||
102 | 7 | private function getUriFromEnvironmentWithHTTP(array $environment): \Psr\Http\Message\UriInterface |
|
111 | |||
112 | /** |
||
113 | * Return an UploadedFile instance array. |
||
114 | * |
||
115 | * @param array $files A array which respect $_FILES structure |
||
116 | * |
||
117 | * @throws InvalidArgumentException for unrecognized values |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | private static function normalizeFiles(array $files): array |
||
140 | |||
141 | /** |
||
142 | * Create and return an UploadedFile instance from a $_FILES specification. |
||
143 | * |
||
144 | * If the specification represents an array of values, this method will |
||
145 | * delegate to normalizeNestedFileSpec() and return that return value. |
||
146 | * |
||
147 | * @param array $value $_FILES struct |
||
148 | * |
||
149 | * @return array|UploadedFileInterface |
||
150 | */ |
||
151 | private static function createUploadedFileFromSpec(array $value) |
||
165 | |||
166 | /** |
||
167 | * Normalize an array of file specifications. |
||
168 | * |
||
169 | * Loops through all nested files and returns a normalized array of |
||
170 | * UploadedFileInterface instances. |
||
171 | * |
||
172 | * @param array $files |
||
173 | * |
||
174 | * @return UploadedFileInterface[] |
||
175 | */ |
||
176 | private static function normalizeNestedFileSpec(array $files = []): array |
||
193 | } |
||
194 |