Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename method. #699

Merged
merged 2 commits into from
May 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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