Skip to content

Commit

Permalink
Rename method. (#699)
Browse files Browse the repository at this point in the history
* Rename method.

* Change back to protected.
  • Loading branch information
mingyoung authored and overtrue committed May 15, 2017
1 parent e6cb5a1 commit 661e723
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 46 deletions.
24 changes: 2 additions & 22 deletions src/Foundation/Core/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ final public function __construct(string $clientId, string $clientSecret = null)
*
* @return string
*/
public function getClientId(): string
final public function getClientId(): string
{
return $this->clientId;
}
Expand All @@ -120,7 +120,7 @@ public function setClientId(string $clientId)
*
* @return string|null
*/
public function getClientSecret()
final public function getClientSecret()
{
return $this->clientSecret;
}
Expand All @@ -139,26 +139,6 @@ public function setClientSecret(string $clientSecret)
return $this;
}

/**
* Return the app id.
*
* @return string
*/
public function getAppId()
{
return $this->getClientId();
}

/**
* Return the secret.
*
* @return string
*/
public function getSecret()
{
return $this->getClientSecret();
}

/**
* Get token from cache.
*
Expand Down
2 changes: 1 addition & 1 deletion src/OfficialAccount/Card/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ public function setTicketCacheKey($cacheKey)
public function getTicketCacheKey()
{
if (is_null($this->ticketCacheKey)) {
return $this->ticketCachePrefix.$this->getAccessToken()->getAppId();
return $this->ticketCachePrefix.$this->getAccessToken()->getClientId();
}

return $this->ticketCacheKey;
Expand Down
4 changes: 2 additions & 2 deletions src/OfficialAccount/Js/Js.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function getConfigArray(array $APIs, $debug = false, $beta = false)
*/
public function ticket($forceRefresh = false)
{
$key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getAppId();
$key = self::TICKET_CACHE_PREFIX.$this->getAccessToken()->getClientId();
$ticket = $this->getCache()->fetch($key);

if (!$forceRefresh && !empty($ticket)) {
Expand Down Expand Up @@ -133,7 +133,7 @@ public function signature($url = null, $nonce = null, $timestamp = null)
$ticket = $this->ticket();

$sign = [
'appId' => $this->getAccessToken()->getAppId(),
'appId' => $this->getAccessToken()->getClientId(),
'nonceStr' => $nonce,
'timestamp' => $timestamp,
'url' => $url,
Expand Down
2 changes: 1 addition & 1 deletion src/OfficialAccount/Semantic/Semantic.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function query($keyword, $categories, array $other = [])
$params = [
'query' => $keyword,
'category' => implode(',', (array) $categories),
'appid' => $this->getAccessToken()->getAppId(),
'appid' => $this->getAccessToken()->getClientId(),
];

return $this->parseJSON('json', [self::API_SEARCH, array_merge($params, $other)]);
Expand Down
4 changes: 2 additions & 2 deletions src/OpenPlatform/Api/AbstractOpenPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function __construct(AccessToken $accessToken, Request $request)
*
* @return string
*/
public function getAppId()
public function getClientId()
{
return $this->getAccessToken()->getAppId();
return $this->getAccessToken()->getClientId();
}
}
10 changes: 5 additions & 5 deletions src/OpenPlatform/Api/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BaseApi extends AbstractOpenPlatform
public function getAuthorizationInfo($authCode = null)
{
$params = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
'authorization_code' => $authCode ?: $this->request->get('auth_code'),
];

Expand All @@ -86,7 +86,7 @@ public function getAuthorizationInfo($authCode = null)
public function getAuthorizerToken($appId, $refreshToken)
{
$params = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
'authorizer_appid' => $appId,
'authorizer_refresh_token' => $refreshToken,
];
Expand All @@ -104,7 +104,7 @@ public function getAuthorizerToken($appId, $refreshToken)
public function getAuthorizerInfo($authorizerAppId)
{
$params = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
'authorizer_appid' => $authorizerAppId,
];

Expand All @@ -122,7 +122,7 @@ public function getAuthorizerInfo($authorizerAppId)
public function getAuthorizerOption($authorizerAppId, $optionName)
{
$params = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
'authorizer_appid' => $authorizerAppId,
'option_name' => $optionName,
];
Expand All @@ -142,7 +142,7 @@ public function getAuthorizerOption($authorizerAppId, $optionName)
public function setAuthorizerOption($authorizerAppId, $optionName, $optionValue)
{
$params = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
'authorizer_appid' => $authorizerAppId,
'option_name' => $optionName,
'option_value' => $optionValue,
Expand Down
4 changes: 2 additions & 2 deletions src/OpenPlatform/Api/PreAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PreAuthorization extends AbstractOpenPlatform
public function getCode()
{
$data = [
'component_appid' => $this->getAppId(),
'component_appid' => $this->getClientId(),
];

$result = $this->parseJSON('json', [self::CREATE_PRE_AUTH_CODE, $data]);
Expand All @@ -74,7 +74,7 @@ public function getCode()
public function redirect($url)
{
return new RedirectResponse(
sprintf(self::PRE_AUTH_LINK, $this->getAppId(), $this->getCode(), urlencode($url))
sprintf(self::PRE_AUTH_LINK, $this->getClientId(), $this->getCode(), urlencode($url))
);
}
}
4 changes: 2 additions & 2 deletions src/OpenPlatform/Core/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function setVerifyTicket(VerifyTicket $verifyTicket)
public function requestFields(): array
{
return [
'component_appid' => $this->clientId,
'component_appsecret' => $this->clientSecret,
'component_appid' => $this->getClientId(),
'component_appsecret' => $this->getClientSecret(),
'component_verify_ticket' => $this->verifyTicket->getTicket(),
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/OpenPlatform/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function register(Container $pimple)
'wechat_open' => [
'client_id' => $pimple['open_platform.authorizer_access_token']->getAppId(),
'client_secret' => [
$pimple['open_platform.access_token']->getAppId(),
$pimple['open_platform.access_token']->getClientId(),
$pimple['open_platform.access_token']->getToken(),
],
'redirect' => $callback,
Expand Down
8 changes: 4 additions & 4 deletions tests/OfficialAccount/Core/CoreAccessTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ public function testGetterAndSetter()
{
$accessToken = new AccessToken('appId', 'secret');

$this->assertEquals('secret', $accessToken->getSecret());
$this->assertEquals('appId', $accessToken->getAppId());
$this->assertEquals('secret', $accessToken->getClientSecret());
$this->assertEquals('appId', $accessToken->getClientId());

$this->assertInstanceOf(\Doctrine\Common\Cache\FilesystemCache::class, $accessToken->getCache());

Expand Down Expand Up @@ -131,8 +131,8 @@ public function testSetToken()
{
$accessToken = new AccessToken('appId', 'secret');

$this->assertEquals('secret', $accessToken->getSecret());
$this->assertEquals('appId', $accessToken->getAppId());
$this->assertEquals('secret', $accessToken->getClientSecret());
$this->assertEquals('appId', $accessToken->getClientId());

$this->assertInstanceOf(\Doctrine\Common\Cache\FilesystemCache::class, $accessToken->getCache());

Expand Down
4 changes: 2 additions & 2 deletions tests/OpenPlatform/Api/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ protected function mockPreAuthorization($appId, $code = null)
return $preAuth;
}

public function testGetAppId()
public function testGetClientId()
{
$api = new OpenPlatformApi($this->getAccessToken('app_id'), $this->getRequest());

$this->assertEquals('app_id', $api->getAppId());
$this->assertEquals('app_id', $api->getClientId());
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OpenPlatform/Api/PreAuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

class PreAuthorizationTest extends ApiTest
{
public function testGetAppId()
public function testGetClientId()
{
$this->assertEquals('appid@foobar', $this->mockPreAuthorization('appid@foobar')->getAppId());
$this->assertEquals('appid@foobar', $this->mockPreAuthorization('appid@foobar')->getClientId());
}

public function testGetCode()
Expand Down

0 comments on commit 661e723

Please sign in to comment.