From a3f5d20592d60983aee826eb5a4ca946e9fa349f Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 30 Sep 2014 22:28:38 +0100 Subject: [PATCH] Changed method names to be clearer that we're setting params --- src/Grant/AuthCodeGrant.php | 6 +++--- src/Grant/ClientCredentialsGrant.php | 4 ++-- src/Grant/PasswordGrant.php | 6 +++--- src/Grant/RefreshTokenGrant.php | 6 +++--- src/TokenType/AbstractTokenType.php | 4 ++-- src/TokenType/Bearer.php | 8 ++++---- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index 7be2487c..d73c8af9 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -230,15 +230,15 @@ class AuthCodeGrant extends AbstractGrant $accessToken->associateScope($scope); } - $this->server->getTokenType()->set('access_token', $accessToken->getId()); - $this->server->getTokenType()->set('expires_in', $this->getAccessTokenTTL()); + $this->server->getTokenType()->setParam('access_token', $accessToken->getId()); + $this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL()); // Associate a refresh token if set if ($this->server->hasGrantType('refresh_token')) { $refreshToken = new RefreshTokenEntity($this->server); $refreshToken->setId(SecureKey::generate()); $refreshToken->setExpireTime($this->server->getGrantType('refresh_token')->getRefreshTokenTTL() + time()); - $this->server->getTokenType()->set('refresh_token', $refreshToken->getId()); + $this->server->getTokenType()->setParam('refresh_token', $refreshToken->getId()); } // Expire the auth code diff --git a/src/Grant/ClientCredentialsGrant.php b/src/Grant/ClientCredentialsGrant.php index 11419c28..94e1094c 100644 --- a/src/Grant/ClientCredentialsGrant.php +++ b/src/Grant/ClientCredentialsGrant.php @@ -112,8 +112,8 @@ class ClientCredentialsGrant extends AbstractGrant $accessToken->setSession($session); $accessToken->save($this->server->getStorage('access_token')); - $this->server->getTokenType()->set('access_token', $accessToken->getId()); - $this->server->getTokenType()->set('expires_in', $this->getAccessTokenTTL()); + $this->server->getTokenType()->setParam('access_token', $accessToken->getId()); + $this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL()); return $this->server->getTokenType()->generateResponse(); } diff --git a/src/Grant/PasswordGrant.php b/src/Grant/PasswordGrant.php index 8798c0e5..4fb35126 100644 --- a/src/Grant/PasswordGrant.php +++ b/src/Grant/PasswordGrant.php @@ -148,15 +148,15 @@ class PasswordGrant extends AbstractGrant $accessToken->associateScope($scope); } - $this->server->getTokenType()->set('access_token', $accessToken->getId()); - $this->server->getTokenType()->set('expires_in', $this->getAccessTokenTTL()); + $this->server->getTokenType()->setParam('access_token', $accessToken->getId()); + $this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL()); // Associate a refresh token if set if ($this->server->hasGrantType('refresh_token')) { $refreshToken = new RefreshTokenEntity($this->server); $refreshToken->setId(SecureKey::generate()); $refreshToken->setExpireTime($this->server->getGrantType('refresh_token')->getRefreshTokenTTL() + time()); - $this->server->getTokenType()->set('refresh_token', $refreshToken->getId()); + $this->server->getTokenType()->setParam('refresh_token', $refreshToken->getId()); } // Save everything diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index c99f19be..1bfe9e68 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -139,8 +139,8 @@ class RefreshTokenGrant extends AbstractGrant $oldAccessToken->expire($this->server->getStorage('access_token')); $newAccessToken->save($this->server->getStorage('access_token')); - $this->server->getTokenType()->set('access_token', $newAccessToken->getId()); - $this->server->getTokenType()->set('expires_in', $this->getAccessTokenTTL()); + $this->server->getTokenType()->setParam('access_token', $newAccessToken->getId()); + $this->server->getTokenType()->setParam('expires_in', $this->getAccessTokenTTL()); // Expire the old refresh token $oldRefreshToken->expire($this->server->getStorage('refresh_token')); @@ -152,7 +152,7 @@ class RefreshTokenGrant extends AbstractGrant $newRefreshToken->setAccessToken($newAccessToken); $newRefreshToken->save($this->server->getStorage('refresh_token')); - $this->server->getTokenType()->set('refresh_token', $newRefreshToken->getId()); + $this->server->getTokenType()->setParam('refresh_token', $newRefreshToken->getId()); return $this->server->getTokenType()->generateResponse(); } diff --git a/src/TokenType/AbstractTokenType.php b/src/TokenType/AbstractTokenType.php index 56266ac0..fb6cd6fb 100644 --- a/src/TokenType/AbstractTokenType.php +++ b/src/TokenType/AbstractTokenType.php @@ -42,7 +42,7 @@ abstract class AbstractTokenType * @param string $key * @param mixed $value */ - public function set($key, $value) + public function setParam($key, $value) { $this->response[$key] = $value; } @@ -52,7 +52,7 @@ abstract class AbstractTokenType * @param string $key * @return mixed */ - public function get($key) + public function getParam($key) { return isset($this->response[$key]) ? $this->response[$key] : null; } diff --git a/src/TokenType/Bearer.php b/src/TokenType/Bearer.php index e6e92a29..bedb0279 100644 --- a/src/TokenType/Bearer.php +++ b/src/TokenType/Bearer.php @@ -21,13 +21,13 @@ class Bearer extends AbstractTokenType implements TokenTypeInterface public function generateResponse() { $return = [ - 'access_token' => $this->get('access_token'), + 'access_token' => $this->getParam('access_token'), 'token_type' => 'Bearer', - 'expires_in' => $this->get('expires_in') + 'expires_in' => $this->getParam('expires_in') ]; - if (!is_null($this->get('refresh_token'))) { - $return['refresh_token'] = $this->get('refresh_token'); + if (!is_null($this->getParam('refresh_token'))) { + $return['refresh_token'] = $this->getParam('refresh_token'); } return $return;