original_string: private function convertRequest(BrowserKitRequest $request)
      {
          $environment = Environment::mock($request->getServer());
          $uri = Uri::createFromString($request->getUri());
          $headers = Headers::createFromEnvironment($environment);
          $cookies = Cookies::parseHeader($headers->get('Cookie', []));
  
          $container = $this->app->getContainer();
  
          /* @var $slimRequest ServerRequestInterface */
          $slimRequest = $container->get('request');
  
          $slimRequest = $slimRequest->withMethod($request->getMethod())
            ->withUri($uri)
            ->withUploadedFiles($this->convertFiles($request->getFiles()))
            ->withCookieParams($cookies);
  
          foreach ($headers->keys() as $key) {
              $slimRequest = $slimRequest->withHeader($key, $headers->get($key));
          }
  
          if ($request->getContent() !== null) {
              $body = new RequestBody();
              $body->write($request->getContent());
              $slimRequest = $slimRequest
                  ->withBody($body);
          }
  
          $parsed = [];
          if ($request->getMethod() !== 'GET') {
              $parsed = $request->getParameters();
          }
  
          // make sure we do not overwrite a request with a parsed body
          if (!$slimRequest->getParsedBody()) {
              $slimRequest = $slimRequest
                  ->withParsedBody($parsed);
          }
  
          return $slimRequest;
      }
code: private function convertRequest(BrowserKitRequest $request)
      {
          $environment = Environment::mock($request->getServer());
          $uri = Uri::createFromString($request->getUri());
          $headers = Headers::createFromEnvironment($environment);
          $cookies = Cookies::parseHeader($headers->get('Cookie', []));
  
          $container = $this->app->getContainer();
  
          /* @var $slimRequest ServerRequestInterface */
          $slimRequest = $container->get('request');
  
          $slimRequest = $slimRequest->withMethod($request->getMethod())
            ->withUri($uri)
            ->withUploadedFiles($this->convertFiles($request->getFiles()))
            ->withCookieParams($cookies);
  
          foreach ($headers->keys() as $key) {
              $slimRequest = $slimRequest->withHeader($key, $headers->get($key));
          }
  
          if ($request->getContent() !== null) {
              $body = new RequestBody();
              $body->write($request->getContent());
              $slimRequest = $slimRequest
                  ->withBody($body);
          }
  
          $parsed = [];
          if ($request->getMethod() !== 'GET') {
              $parsed = $request->getParameters();
          }
  
          // make sure we do not overwrite a request with a parsed body
          if (!$slimRequest->getParsedBody()) {
              $slimRequest = $slimRequest
                  ->withParsedBody($parsed);
          }
  
          return $slimRequest;
      }
code_tokens: private function convertRequest ( BrowserKitRequest $ request ) { $ environment = Environment :: mock ( $ request -> getServer ( ) ) ; $ uri = Uri :: createFromString ( $ request -> getUri ( ) ) ; $ headers = Headers :: createFromEnvironment ( $ environment ) ; $ cookies = Cookies :: parseHeader ( $ headers -> get ( 'Cookie' , [ ] ) ) ; $ container = $ this -> app -> getContainer ( ) ; /* @var $slimRequest ServerRequestInterface */ $ slimRequest = $ container -> get ( 'request' ) ; $ slimRequest = $ slimRequest -> withMethod ( $ request -> getMethod ( ) ) -> withUri ( $ uri ) -> withUploadedFiles ( $ this -> convertFiles ( $ request -> getFiles ( ) ) ) -> withCookieParams ( $ cookies ) ; foreach ( $ headers -> keys ( ) as $ key ) { $ slimRequest = $ slimRequest -> withHeader ( $ key , $ headers -> get ( $ key ) ) ; } if ( $ request -> getContent ( ) !== null ) { $ body = new RequestBody ( ) ; $ body -> write ( $ request -> getContent ( ) ) ; $ slimRequest = $ slimRequest -> withBody ( $ body ) ; } $ parsed = [ ] ; if ( $ request -> getMethod ( ) !== 'GET' ) { $ parsed = $ request -> getParameters ( ) ; } // make sure we do not overwrite a request with a parsed body if ( ! $ slimRequest -> getParsedBody ( ) ) { $ slimRequest = $ slimRequest -> withParsedBody ( $ parsed ) ; } return $ slimRequest ; }
docstring: Convert to PSR-7's ServerRequestInterface.
  
  @param BrowserKitRequest $request
  @return ServerRequestInterface
docstring_tokens: Convert to PSR - 7 s ServerRequestInterface .