title: How to get the query parameters in a Guzzle/ Psr7 request
body: <p>I am using Guzzle 6.</p>
  
  <p>I am trying to mock a client and use it like so:</p>
  
  <pre><code>&lt;?php
  
  use GuzzleHttp\Client;
  use GuzzleHttp\Handler\MockHandler;
  use GuzzleHttp\HandlerStack;
  use GuzzleHttp\Middleware;
  use GuzzleHttp\Psr7\Request;
  use GuzzleHttp\Psr7\Response;
  
  $mock_handler = new MockHandler([
      new Response(200, ['Content-Type' =&gt; 'application/json'], 'foo'),
  ]);
  
  $history = [];
  $history_middleware = Middleware::history($history);
  
  $handler_stack = HandlerStack::create($mock_handler);
  $handler_stack-&gt;push($history_middleware);
  
  $mock_client = new Client(['handler' =&gt; $handler_stack]);
  
  // Use mock client in some way
  $mock_client-&gt;get("http://example.com", [
      'query' =&gt; [
          'bar' =&gt; '10',
          'hello' =&gt; '20'
      ],
  ]);
  // ------
  
  // get original request using history
  $transaction = $history[0];
  /** @var Request $request */
  $request = $transaction['request'];
  
  // How can I get the query parameters that was used in the request (i.e. bar)
  </code></pre>
  
  <p>My question is how can I get the query parameters used in the <code>GuzzleHttp\Psr7\Request</code> class?</p>
  
  <p>The closest I managed to get is the following: <code>$request-&gt;getUri()-&gt;getQuery()</code>, but this just returns a string like so: <code>bar=10&amp;hello=20</code>.</p>