Skip to content

Commit

Permalink
Apply fixes from StyleCI (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: iMactool <[email protected]>
  • Loading branch information
iMactool and iMactool authored Apr 19, 2021
1 parent 9282bf2 commit 3f5d6ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
// 授权方已经把店铺授权给你的抖店开放平台了,接下来的代授权方实现业务只需一行代码即可获得授权方实例。
$shopid = 2322; //$shopid 为授权方店铺的ID shop_id
$refresh_token = '授权店铺token'; //$refresh_token 为授权方的 refresh_token,
$app = $servic->shopApp($shopid,$refresh_token);
$app = $servic->shopApp($shopid, $refresh_token);

//获取店铺的已授权品牌列表
try {
Expand Down
5 changes: 2 additions & 3 deletions src/Core/BaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ class BaseService
public function __construct(Container $app)
{
$this->app = $app;
if (property_exists($app,'shopId')){
if (property_exists($app, 'shopId')) {
$config['shopId'] = $app->shopId;
$config['refreshToken'] = $app->refreshToken;
self::setAppConfig('shop',$config);
self::setAppConfig('shop', $config);
}
$this->appRunConfig = self::getAppConfig();

}
}
6 changes: 4 additions & 2 deletions src/DouDianApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ class DouDianApp extends ContainerBase
public function __construct(array $config)
{
self::$config = $config;
Client::setAppConfig('config',$config);
Client::setAppConfig('config', $config);
parent::__construct();
}

public function shopApp(int $shopId, string $refreshToken){
public function shopApp(int $shopId, string $refreshToken)
{
parent::__construct();
$this->shopId = $shopId;
$this->refreshToken = $refreshToken;

return $this;
}
}
26 changes: 15 additions & 11 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Imactool\Jinritemai\Http;


trait Client
{
use AuthService;
Expand All @@ -22,35 +21,40 @@ public function httpClient()
if (!self::$client) {
self::$client = new Http();
}

return self::$client;
}

public static function setAppConfig($key,$appConfig)
public static function setAppConfig($key, $appConfig)
{
self::$appConfig[$key] = $appConfig;
self::$appConfig[$key] = $appConfig;
}

public static function getAppConfig($key=null)
public static function getAppConfig($key = null)
{
if (is_null($key)){
if (is_null($key)) {
return self::$appConfig['config'];
}

return self::$appConfig['config'][$key];
}

public static function setShopConfig($shopConfig){
self::$appConfig = array_merge(self::getAppConfig() , $shopConfig);
public static function setShopConfig($shopConfig)
{
self::$appConfig = array_merge(self::getAppConfig(), $shopConfig);
}

public static function getShopConfig($key = null){
if (is_null($key)){
public static function getShopConfig($key = null)
{
if (is_null($key)) {
return self::$appConfig['shop'];
}
return self::$appConfig['shop'][$key];

return self::$appConfig['shop'][$key];
}

public static function getAllConfig(){
public static function getAllConfig()
{
return self::$appConfig;
}

Expand Down

0 comments on commit 3f5d6ca

Please sign in to comment.