diff --git a/.travis.yml b/.travis.yml index 23dcedd..5d5675e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,4 @@ install: - composer install script: - - ./vendor/bin/phpunit -c ./phpunit.xml --coverage-text \ No newline at end of file + - ./vendor/bin/phpunit -c ./phpunit.xml --coverage-text diff --git a/README.md b/README.md index 6a72282..3df27da 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ guzzle-oauth2-plugin ==================== -Provides an OAuth2 plugin for [Guzzle](http://guzzlephp.org/). +Provides an OAuth2 plugin (subscriber) for [Guzzle](http://guzzlephp.org/). [![Build Status](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin.svg)](https://travis-ci.org/commerceguys/guzzle-oauth2-plugin) -The `master` branch is intended for Guzzle 5: +Version 2.x (on the `master` branch) is intended for Guzzle 5: ```json - "commerceguys/guzzle-oauth2-plugin": "dev-master" + "commerceguys/guzzle-oauth2-plugin": "~2.0" ``` Guzzle 3 compatibility continues in the [`1.0`](https://github.com/commerceguys/guzzle-oauth2-plugin/tree/1.0) branch: @@ -52,12 +52,11 @@ $client = new Client([ ], ]); -/** @var \GuzzleHttp\Message\Response */ $response = $client->get('https://example.com/api/user/me'); print_r($response->json()); -// Use $oauth2->getAccessToken(); to get a token that can be persisted for -// subsequent requests. +// Use $oauth2->getAccessToken(); and $oauth2->getRefreshToken() to get tokens +// that can be persisted for subsequent requests. ``` diff --git a/composer.json b/composer.json index ab14252..41ec514 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "commerceguys/guzzle-oauth2-plugin", - "description": "An OAuth2 plugin for Guzzle 5.x", + "description": "An OAuth2 plugin (subscriber) for Guzzle 5.x", "license": "MIT", "require": { "guzzlehttp/guzzle": "~5.0" diff --git a/composer.lock b/composer.lock index 96e8c66..b0faf19 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "62c97330a058c3178f364fdcac164a60", + "hash": "aa6a34af010b810e5fb3a7e678a89cbe", "packages": [ { "name": "guzzlehttp/guzzle", diff --git a/src/AccessToken.php b/src/AccessToken.php index eca4208..d560d3a 100644 --- a/src/AccessToken.php +++ b/src/AccessToken.php @@ -21,8 +21,8 @@ class AccessToken /** * @param string $token - * @param string $type The token type (from OAuth2 key 'token_type'). - * @param array $data Other token data. + * @param string $type The token type (from OAuth2 key 'token_type'). + * @param array $data Other token data. */ public function __construct($token, $type, array $data = []) { diff --git a/src/GrantType/AuthorizationCode.php b/src/GrantType/AuthorizationCode.php index cd4ce54..08acf41 100644 --- a/src/GrantType/AuthorizationCode.php +++ b/src/GrantType/AuthorizationCode.php @@ -4,6 +4,7 @@ /** * Authorization code grant type. + * * @link http://tools.ietf.org/html/rfc6749#section-4.1 */ class AuthorizationCode extends GrantTypeBase diff --git a/src/GrantType/ClientCredentials.php b/src/GrantType/ClientCredentials.php index a1750fa..ec0ffd5 100644 --- a/src/GrantType/ClientCredentials.php +++ b/src/GrantType/ClientCredentials.php @@ -4,6 +4,7 @@ /** * Client credentials grant type. + * * @link http://tools.ietf.org/html/rfc6749#section-4.4 */ class ClientCredentials extends GrantTypeBase diff --git a/src/GrantType/GrantTypeBase.php b/src/GrantType/GrantTypeBase.php index 0b5df58..d5dc83a 100644 --- a/src/GrantType/GrantTypeBase.php +++ b/src/GrantType/GrantTypeBase.php @@ -3,8 +3,8 @@ namespace CommerceGuys\Guzzle\Oauth2\GrantType; use CommerceGuys\Guzzle\Oauth2\AccessToken; -use GuzzleHttp\Collection; use GuzzleHttp\ClientInterface; +use GuzzleHttp\Collection; abstract class GrantTypeBase implements GrantTypeInterface { diff --git a/src/GrantType/PasswordCredentials.php b/src/GrantType/PasswordCredentials.php index eeffa44..3fa3488 100644 --- a/src/GrantType/PasswordCredentials.php +++ b/src/GrantType/PasswordCredentials.php @@ -4,6 +4,7 @@ /** * Resource owner password credentials grant type. + * * @link http://tools.ietf.org/html/rfc6749#section-4.3 */ class PasswordCredentials extends GrantTypeBase diff --git a/src/GrantType/RefreshToken.php b/src/GrantType/RefreshToken.php index c486b04..fc974df 100644 --- a/src/GrantType/RefreshToken.php +++ b/src/GrantType/RefreshToken.php @@ -4,6 +4,7 @@ /** * Refresh token grant type. + * * @link http://tools.ietf.org/html/rfc6749#section-6 */ class RefreshToken extends GrantTypeBase implements RefreshTokenGrantTypeInterface diff --git a/src/Oauth2Subscriber.php b/src/Oauth2Subscriber.php index 9e796ec..29785ba 100644 --- a/src/Oauth2Subscriber.php +++ b/src/Oauth2Subscriber.php @@ -25,7 +25,7 @@ class Oauth2Subscriber implements SubscriberInterface /** * Create a new Oauth2 subscriber. * - * @param GrantTypeInterface $grantType + * @param GrantTypeInterface $grantType * @param RefreshTokenGrantTypeInterface $refreshTokenGrantType */ public function __construct(GrantTypeInterface $grantType = null, RefreshTokenGrantTypeInterface $refreshTokenGrantType = null) @@ -40,8 +40,8 @@ public function __construct(GrantTypeInterface $grantType = null, RefreshTokenGr public function getEvents() { return [ - 'before' => ['onBefore', RequestEvents::SIGN_REQUEST], - 'error' => ['onError', RequestEvents::EARLY], + 'before' => ['onBefore', RequestEvents::SIGN_REQUEST], + 'error' => ['onError', RequestEvents::EARLY], ]; } @@ -141,8 +141,8 @@ public function getRefreshToken() * Set the access token. * * @param AccessToken|string $accessToken - * @param string $type - * @param int $expires + * @param string $type + * @param int $expires */ public function setAccessToken($accessToken, $type = null, $expires = null) { diff --git a/tests/MockOAuth2Server.php b/tests/MockOAuth2Server.php index 47dc2c0..4072a03 100644 --- a/tests/MockOAuth2Server.php +++ b/tests/MockOAuth2Server.php @@ -37,8 +37,7 @@ protected function getResult(array $request) { if ($request['uri'] === $this->options['tokenPath']) { $response = $this->oauth2Token($request); - } - elseif (strpos($request['uri'], 'api/') !== false) { + } elseif (strpos($request['uri'], 'api/') !== false) { $response = $this->mockApiCall($request); } if (!isset($response)) { @@ -85,8 +84,7 @@ protected function validTokenResponse() if (isset($this->options['tokenExpires'])) { $token['expires'] = $this->options['tokenExpires']; - } - elseif (isset($this->options['tokenExpiresIn'])) { + } elseif (isset($this->options['tokenExpiresIn'])) { $token['expires_in'] = $this->options['tokenExpiresIn']; } diff --git a/tests/TestBase.php b/tests/TestBase.php index d2f0264..0b15f48 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -16,7 +16,7 @@ protected function getClient(array $options = [], array $serverOptions = []) { $server = new MockOAuth2Server($serverOptions); return new Client([ - 'handler' => $server->getHandler() - ] + $options); + 'handler' => $server->getHandler() + ] + $options); } }