1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 18:43:22 +01:00

Optimizing if statement when creating client requests

This commit is contained in:
Michael Dowling 2013-02-23 18:53:23 -08:00
parent 9621c17941
commit cb8e0c7ea6

View File

@ -258,10 +258,10 @@ class Client extends AbstractHasDispatcher implements ClientInterface
// If default headers are provided, then merge them into existing headers
// If a collision occurs, the header is completely replaced
if (count($this->defaultHeaders)) {
if ($headers instanceof Collection) {
if (is_array($headers)) {
$headers = array_merge($this->defaultHeaders->getAll(), $headers);
} elseif ($headers instanceof Collection) {
$headers = array_merge($this->defaultHeaders->getAll(), $headers->getAll());
} elseif (is_array($headers)) {
$headers = array_merge($this->defaultHeaders->getAll(), $headers);
} else {
$headers = $this->defaultHeaders;
}