function ServerRequestCreator::normalizeFiles
Return an UploadedFile instance array.
Parameters
array $files A array which respect $_FILES structure:
Return value
Throws
\InvalidArgumentException for unrecognized values
1 call to ServerRequestCreator::normalizeFiles()
- ServerRequestCreator::fromArrays in vendor/
nyholm/ psr7-server/ src/ ServerRequestCreator.php - Create a new server request from a set of arrays.
File
-
vendor/
nyholm/ psr7-server/ src/ ServerRequestCreator.php, line 180
Class
- ServerRequestCreator
- @author Tobias Nyholm <tobias.nyholm@gmail.com> @author Martijn van der Ven <martijn@vanderven.se>
Namespace
Nyholm\Psr7ServerCode
private function normalizeFiles(array $files) : array {
$normalized = [];
foreach ($files as $key => $value) {
if ($value instanceof UploadedFileInterface) {
$normalized[$key] = $value;
}
elseif (\is_array($value) && isset($value['tmp_name'])) {
$normalized[$key] = $this->createUploadedFileFromSpec($value);
}
elseif (\is_array($value)) {
$normalized[$key] = $this->normalizeFiles($value);
}
else {
throw new \InvalidArgumentException('Invalid value in files specification');
}
}
return $normalized;
}