You are here

public static function ServerRequest::normalizeFiles in Lockr 7.3

Return an UploadedFile instance array.

Parameters

array $files A array which respect $_FILES structure:

Return value

array

Throws

InvalidArgumentException for unrecognized values

1 call to ServerRequest::normalizeFiles()
ServerRequest::fromGlobals in vendor/guzzlehttp/psr7/src/ServerRequest.php
Return a ServerRequest populated with superglobals: $_GET $_POST $_COOKIE $_FILES $_SERVER

File

vendor/guzzlehttp/psr7/src/ServerRequest.php, line 85

Class

ServerRequest
Server-side HTTP request

Namespace

GuzzleHttp\Psr7

Code

public static function normalizeFiles(array $files) {
  $normalized = [];
  foreach ($files as $key => $value) {
    if ($value instanceof UploadedFileInterface) {
      $normalized[$key] = $value;
    }
    elseif (is_array($value) && isset($value['tmp_name'])) {
      $normalized[$key] = self::createUploadedFileFromSpec($value);
    }
    elseif (is_array($value)) {
      $normalized[$key] = self::normalizeFiles($value);
      continue;
    }
    else {
      throw new InvalidArgumentException('Invalid value in files specification');
    }
  }
  return $normalized;
}