diff --git a/src/Client/Cookies.php b/src/Client/Cookies.php index da3c1b62f5..162e0f519f 100644 --- a/src/Client/Cookies.php +++ b/src/Client/Cookies.php @@ -137,12 +137,8 @@ public function addCookie($cookie, $ref_uri = null) * @param Response $response * @param Uri\Uri|string $ref_uri Requested URI */ - public function addCookiesFromResponse($response, $ref_uri) + public function addCookiesFromResponse(Response $response, $ref_uri) { - if (!$response instanceof Response) { - throw new Exception\InvalidArgumentException('$response is expected to be a Response object'); - } - $cookie_hdrs = $response->headers()->get('Set-Cookie'); if (is_array($cookie_hdrs)) { @@ -182,8 +178,7 @@ public function getMatchingCookies($uri, $matchSessionCookies = true, { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); - } - if (!$uri instanceof Uri\Uri) { + } elseif (!$uri instanceof Uri\Uri) { throw new Exception\InvalidArgumentException("Invalid URI string or object passed"); } @@ -221,9 +216,7 @@ public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT) { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); - } - - if (!$uri instanceof Uri\Uri) { + } elseif (!$uri instanceof Uri\Uri) { throw new Exception\InvalidArgumentException('Invalid URI specified'); } diff --git a/src/Cookies.php b/src/Cookies.php index b9927973ca..ea8941561e 100755 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -140,12 +140,8 @@ public function addCookie(Cookie $cookie, $ref_uri = null) * @param Response $response * @param Uri\Uri|string $ref_uri Requested URI */ - public function addCookiesFromResponse($response, $ref_uri) + public function addCookiesFromResponse(Response $response, $ref_uri) { - if (!$response instanceof Response) { - throw new Exception\InvalidArgumentException('$response is expected to be a Response object'); - } - $cookie_hdrs = $response->headers()->get('Set-Cookie'); if (is_array($cookie_hdrs)) { @@ -185,8 +181,7 @@ public function getMatchingCookies($uri, $matchSessionCookies = true, { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); - } - if (!$uri instanceof Uri\Uri) { + } elseif (!$uri instanceof Uri\Uri) { throw new Exception\InvalidArgumentException("Invalid URI string or object passed"); } @@ -224,9 +219,7 @@ public function getCookie($uri, $cookie_name, $ret_as = self::COOKIE_OBJECT) { if (is_string($uri)) { $uri = Uri\UriFactory::factory($uri, 'http'); - } - - if (!$uri instanceof Uri\Uri) { + } elseif (!$uri instanceof Uri\Uri) { throw new Exception\InvalidArgumentException('Invalid URI specified'); }