Making oschwald's style changes and fixing tests

This commit is contained in:
Will Bradley 2015-03-20 19:18:55 -07:00
parent 6f776ffac1
commit 4ec525a313
4 changed files with 9 additions and 8 deletions

View File

@ -314,7 +314,7 @@ If you are using PHP 5.3 with an autoloader besides Composer, you must load
## Contributing ## ## Contributing ##
Patches and pull requests are encouraged. All code should follow the Patches and pull requests are encouraged. All code should follow the
PSR-2 style guidelines. Please include unit tests whenever possible. You may obtain the test data for the maxmind-db folder from https://github.com/maxmind/MaxMind-DB PSR-2 style guidelines. Please include unit tests whenever possible. You may obtain the test data for the maxmind-db folder by running `git submodule update --init --recursive` or adding `--recursive` to your initial clone, or from https://github.com/maxmind/MaxMind-DB
## Versioning ## ## Versioning ##

View File

@ -2,7 +2,6 @@
namespace GeoIp2\Model; namespace GeoIp2\Model;
/** /**
* @ignore * @ignore
*/ */

View File

@ -64,8 +64,8 @@ class Client implements ProviderInterface
* @param string $host Optional host parameter * @param string $host Optional host parameter
* @param object $guzzleClient Optional Guzzle client to use (to facilitate * @param object $guzzleClient Optional Guzzle client to use (to facilitate
* unit testing). * unit testing).
* @param string $timeout Total transaction timeout * @param string $timeout Total transaction timeout in seconds
* @param string $connectTimeout Initial connection timeout * @param string $connectTimeout Initial connection timeout in seconds
*/ */
public function __construct( public function __construct(
$userId, $userId,
@ -189,10 +189,10 @@ class Client implements ProviderInterface
$client = $this->guzzleClient ? $client = $this->guzzleClient ?
$this->guzzleClient : new GuzzleClient(); $this->guzzleClient : new GuzzleClient();
$options = array(); $options = array();
if($this->timeout != null){ if ($this->timeout !== null) {
$options['timeout'] = $this->timeout; $options['timeout'] = $this->timeout;
} }
if($this->connectTimeout != null){ if ($this->connectTimeout !== null) {
$options['connect_timeout'] = $this->connectTimeout; $options['connect_timeout'] = $this->connectTimeout;
} }
$request = $client->get($uri, array('Accept' => 'application/json'), $options); $request = $client->get($uri, array('Accept' => 'application/json'), $options);

View File

@ -451,15 +451,17 @@ class ClientTest extends \PHPUnit_Framework_TestCase
'request sets Accept header to GeoIP2 PHP API (Guzzle%s)' 'request sets Accept header to GeoIP2 PHP API (Guzzle%s)'
); );
$curlOptions = $request->getCurlOptions();
$this->assertEquals( $this->assertEquals(
'27000', '27000',
$request->getCurlOptions()[CURLOPT_TIMEOUT_MS], $curlOptions[CURLOPT_TIMEOUT_MS],
'request sets Curl Option Timeout to 27 seconds' 'request sets Curl Option Timeout to 27 seconds'
); );
$this->assertEquals( $this->assertEquals(
'72000', '72000',
$request->getCurlOptions()[CURLOPT_CONNECTTIMEOUT_MS], $curlOptions[CURLOPT_CONNECTTIMEOUT_MS],
'request sets Curl Option Connect Timeout to 72 seconds' 'request sets Curl Option Connect Timeout to 72 seconds'
); );
} }