Exemple #1
0
 /**
  * Creates a new Request from a specified array.
  *
  * @param  array  $request Request represented as an array.
  *
  * @return Request A new Request from specified array.
  */
 public static function fromArray(array $request)
 {
     $requestObject = new Request($request['method'], $request['url'], $request['headers']);
     if (!empty($request['post_fields']) && is_array($request['post_fields'])) {
         $requestObject->addPostFields($request['post_fields']);
     }
     if (!empty($request['post_files']) && is_array($request['post_files'])) {
         foreach ($request['post_files'] as $file) {
             $requestObject->addPostFile(new PostFile($file['fieldName'], $file['filename'], $file['contentType'], $file['postname']));
         }
     }
     return $requestObject;
 }