guzzle/guzzle — pull request #807 by overtrue (2014-09-05 02:29:32+00:00)
Title: When using an associative array batch requests, easy to handle return values

The current usage:
```php
$client = new GuzzleHttp\Client();

$requests = [
$client->createRequest('GET', 'http://httpbin.org/get'),
$client->createRequest('HEAD', 'http://httpbin.org/get'),
$client->createRequest('PUT', 'http://httpbin.org/put'),
];

$results = GuzzleHttp\batch($client, $requests);

// Results is an SplObjectStorage object where each request is a key
foreach ($requests as $request) {
echo $request->getUrl() . "\n";
// Get the result (either a ResponseInterface or RequestException)
$result = $results[$request];
if ($result instanceof ResponseInterface) {
// Interact with the response directly
echo $result->getStatusCode();
} else {
// Get the exception message
echo $result->getMessage();
}
}
```

But the following will be more convenient usage:

```php
$client = new GuzzleHttp\Client();

$requests = [
'foo' => $client->createRequest('GET', 'http://httpbin.org/get'),
'bar' => $client->createRequest('HEAD', 'http://httpbin.org/get'),
'baz' => $client->createRequest('PUT', 'http://httpbin.org/put'),
];

$results = GuzzleHttp\batch($client, $requests);

// Only need to use the array index get results, rather than foreach

$foo = $results['foo'];
$bar = $results['bar'];
$baz = $results['baz'];

// ...
```

Thanks!