From 6fec6ef89630658e81d54dfe23125fac85492b00 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 15 May 2012 09:57:48 +0200 Subject: [PATCH] fixed CS --- src/Goutte/Client.php | 46 ++++++++++++------------------- tests/Goutte/Tests/ClientTest.php | 31 ++++++--------------- 2 files changed, 26 insertions(+), 51 deletions(-) diff --git a/src/Goutte/Client.php b/src/Goutte/Client.php index 4ff45ce..894f4ae 100644 --- a/src/Goutte/Client.php +++ b/src/Goutte/Client.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Goutte; use Symfony\Component\BrowserKit\Client as BaseClient; @@ -14,15 +23,6 @@ use Guzzle\Service\ClientInterface as GuzzleClientInterface; use Guzzle\Service\Client as GuzzleClient; -/* - * This file is part of the Goutte package. - * - * (c) Fabien Potencier - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - /** * Client. * @@ -32,7 +32,7 @@ */ class Client extends BaseClient { - const VERSION = '0.1'; + const VERSION = '0.2'; protected $headers = array(); protected $auth = null; @@ -75,7 +75,7 @@ public function setAuth($user, $password = '', $type = GuzzleRequestInterface::A protected function doRequest($request) { $guzzleRequest = $this->getClient()->createRequest( - strtoupper($request->getMethod()), + $request->getMethod(), $request->getUri(), $this->headers, $request->getParameters() @@ -93,32 +93,27 @@ protected function doRequest($request) $guzzleRequest->addCookie($name, $value); } - if ($request->getMethod() == 'POST') { + if ('POST' == $request->getMethod()) { foreach ($request->getFiles() as $name => $info) { if (isset($info['tmp_name']) && '' !== $info['tmp_name']) { - $guzzleRequest->addPostFiles(array( - $name => $info['tmp_name'] - )); + $guzzleRequest->addPostFiles(array($name => $info['tmp_name'])); } } } $guzzleRequest->setHeader('User-Agent', $this->server['HTTP_USER_AGENT']); - $guzzleRequest->getCurlOptions()->merge(array( - CURLOPT_MAXREDIRS => 0, - CURLOPT_TIMEOUT => 30 - )); + $guzzleRequest->getCurlOptions()->merge(array(CURLOPT_MAXREDIRS => 0, CURLOPT_TIMEOUT => 30)); // Let BrowserKit handle redirects try { $response = $guzzleRequest->send(); } catch (CurlException $e) { - if (strpos($e->getMessage(), 'redirects')) { - $response = $e->getResponse(); - } else { + if (!strpos($e->getMessage(), 'redirects')) { throw $e; } + + $response = $e->getResponse(); } return $this->createResponse($response); @@ -126,11 +121,6 @@ protected function doRequest($request) protected function createResponse(GuzzleResponse $response) { - return new Response( - $response->getBody(true), - $response->getStatusCode(), - $response->getHeaders()->getAll() - ); + return new Response($response->getBody(true), $response->getStatusCode(), $response->getHeaders()->getAll()); } } - diff --git a/tests/Goutte/Tests/ClientTest.php b/tests/Goutte/Tests/ClientTest.php index 353491d..a95337d 100644 --- a/tests/Goutte/Tests/ClientTest.php +++ b/tests/Goutte/Tests/ClientTest.php @@ -1,28 +1,13 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Goutte\Tests; @@ -164,4 +149,4 @@ public function testHandlesRedirectsCorrectly() // Ensure that two requests were sent $this->assertEquals(2, count($this->history)); } -} \ No newline at end of file +}