Classic algorithm learning-Bubble Sorting
public function __construct($method, UriInterface $uri, HeadersInterface $headers, array $cookies, array $serverParams, StreamInterface $body, array $uploadedFiles = []){ $this->originalMethod = $this->filterMethod($method); $this->uri = $uri; $this->headers = $headers; $this->cookies = $cookies; $this->serverParams = $serverParams; $this->attributes = new Collection(); $this->body = $body; $this->uploadedFiles = $uploadedFiles; if (!$this->headers->has('Host') || $this->uri->getHost() !== '') { $this->headers->set('Host', $this->uri->getHost()); } $this->registerMediaTypeParser('application/json', function ($input) { return json_decode($input, true); }); $this->registerMediaTypeParser('application/xml', function ($input) { return simplexml_load_string($input); }); $this->registerMediaTypeParser('text/xml', function ($input) { return simplexml_load_string($input); }); $this->registerMediaTypeParser('application/x-www-form-urlencoded', function ($input) { parse_str($input, $data); return $data; });}