正在显示
13 个修改的文件
包含
24 行增加
和
20 行删除
| @@ -23,7 +23,8 @@ | @@ -23,7 +23,8 @@ | ||
| 23 | "ext-json": "*" | 23 | "ext-json": "*" |
| 24 | }, | 24 | }, |
| 25 | "require-dev": { | 25 | "require-dev": { |
| 26 | - "phpunit/phpunit": "^9.5.10" | 26 | + "phpunit/phpunit": "^9.5.10", |
| 27 | + "friendsofphp/php-cs-fixer": "^3.7" | ||
| 27 | }, | 28 | }, |
| 28 | "extra": { | 29 | "extra": { |
| 29 | "laravel": { | 30 | "laravel": { |
| @@ -22,8 +22,7 @@ class Config | @@ -22,8 +22,7 @@ class Config | ||
| 22 | string $baseUri = '', | 22 | string $baseUri = '', |
| 23 | float $timeout = 30.0, | 23 | float $timeout = 30.0, |
| 24 | bool $enableMock = false | 24 | bool $enableMock = false |
| 25 | - ) | ||
| 26 | - { | 25 | + ) { |
| 27 | $this->appKey = $appKey; | 26 | $this->appKey = $appKey; |
| 28 | $this->appSecret = $appSecret; | 27 | $this->appSecret = $appSecret; |
| 29 | $this->baseUri = $baseUri; | 28 | $this->baseUri = $baseUri; |
| @@ -5,7 +5,6 @@ namespace Lackoxygen\TiktokShop\Command; | @@ -5,7 +5,6 @@ namespace Lackoxygen\TiktokShop\Command; | ||
| 5 | use Lackoxygen\TiktokShop\Supervisor\Session\SessionHeart; | 5 | use Lackoxygen\TiktokShop\Supervisor\Session\SessionHeart; |
| 6 | use Illuminate\Console\Command; | 6 | use Illuminate\Console\Command; |
| 7 | 7 | ||
| 8 | - | ||
| 9 | class RefreshToken extends Command | 8 | class RefreshToken extends Command |
| 10 | { | 9 | { |
| 11 | /** | 10 | /** |
| @@ -15,7 +15,8 @@ use Illuminate\Support\Arr; | @@ -15,7 +15,8 @@ use Illuminate\Support\Arr; | ||
| 15 | 15 | ||
| 16 | class Mock | 16 | class Mock |
| 17 | { | 17 | { |
| 18 | - protected string $passage, $method; | 18 | + protected string $passage; |
| 19 | + protected string $method; | ||
| 19 | 20 | ||
| 20 | protected Annotation $annotation; | 21 | protected Annotation $annotation; |
| 21 | 22 | ||
| @@ -24,7 +25,7 @@ class Mock | @@ -24,7 +25,7 @@ class Mock | ||
| 24 | $this->passage = $passage; | 25 | $this->passage = $passage; |
| 25 | $this->method = $method; | 26 | $this->method = $method; |
| 26 | 27 | ||
| 27 | - $this->annotation = new Annotation; | 28 | + $this->annotation = new Annotation(); |
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | 31 |
| @@ -17,7 +17,7 @@ class SessionHeart | @@ -17,7 +17,7 @@ class SessionHeart | ||
| 17 | public static function new(): SessionHeart | 17 | public static function new(): SessionHeart |
| 18 | { | 18 | { |
| 19 | if (is_null(static::$sessionHeart)) { | 19 | if (is_null(static::$sessionHeart)) { |
| 20 | - static::$sessionHeart = new static; | 20 | + static::$sessionHeart = new static(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | return static::$sessionHeart; | 23 | return static::$sessionHeart; |
| @@ -58,8 +58,13 @@ class TiktokShop | @@ -58,8 +58,13 @@ class TiktokShop | ||
| 58 | */ | 58 | */ |
| 59 | public static function newConfig(array $options): Config | 59 | public static function newConfig(array $options): Config |
| 60 | { | 60 | { |
| 61 | - return new Config(Arr::get($options, 'app_key'), Arr::get($options, 'app_secret'), | ||
| 62 | - Arr::get($options, 'base_uri'), (float)Arr::get($options, 'timeout'), Arr::get($options, 'enable_mock')); | 61 | + return new Config( |
| 62 | + Arr::get($options, 'app_key'), | ||
| 63 | + Arr::get($options, 'app_secret'), | ||
| 64 | + Arr::get($options, 'base_uri'), | ||
| 65 | + (float)Arr::get($options, 'timeout'), | ||
| 66 | + Arr::get($options, 'enable_mock') | ||
| 67 | + ); | ||
| 63 | } | 68 | } |
| 64 | 69 | ||
| 65 | /** | 70 | /** |
| @@ -15,11 +15,12 @@ class Builder | @@ -15,11 +15,12 @@ class Builder | ||
| 15 | 15 | ||
| 16 | protected Config $config; | 16 | protected Config $config; |
| 17 | 17 | ||
| 18 | - protected string $passage, $method; | 18 | + protected string $passage; |
| 19 | + protected string $method; | ||
| 19 | 20 | ||
| 20 | public function __construct(Config $config, string $passage, string $method) | 21 | public function __construct(Config $config, string $passage, string $method) |
| 21 | { | 22 | { |
| 22 | - $this->request = new Request; | 23 | + $this->request = new Request(); |
| 23 | $this->config = $config; | 24 | $this->config = $config; |
| 24 | $this->request->setConfig($config); | 25 | $this->request->setConfig($config); |
| 25 | $this->passage = $passage; | 26 | $this->passage = $passage; |
| @@ -17,7 +17,7 @@ class Client | @@ -17,7 +17,7 @@ class Client | ||
| 17 | { | 17 | { |
| 18 | public static function create(): Client | 18 | public static function create(): Client |
| 19 | { | 19 | { |
| 20 | - return new self; | 20 | + return new self(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| @@ -37,7 +37,7 @@ class Client | @@ -37,7 +37,7 @@ class Client | ||
| 37 | */ | 37 | */ |
| 38 | protected function signature(Request $request): ?string | 38 | protected function signature(Request $request): ?string |
| 39 | { | 39 | { |
| 40 | - $sig = new Signature; | 40 | + $sig = new Signature(); |
| 41 | $sig->setTimestamp($request->getTimestamp()); | 41 | $sig->setTimestamp($request->getTimestamp()); |
| 42 | $sig->setMethod($request->getService()); | 42 | $sig->setMethod($request->getService()); |
| 43 | $sig->setAppKey($request->getConfig()->getAppKey()); | 43 | $sig->setAppKey($request->getConfig()->getAppKey()); |
| @@ -107,8 +107,11 @@ class Client | @@ -107,8 +107,11 @@ class Client | ||
| 107 | 107 | ||
| 108 | $retry = new Retry(function () use ($request, $options) { | 108 | $retry = new Retry(function () use ($request, $options) { |
| 109 | return $this->guzzleHttp($request->getConfig()) | 109 | return $this->guzzleHttp($request->getConfig()) |
| 110 | - ->request($request->getMethod(), $request->getPath() ?: $this->serviceToPath($request->getService()), | ||
| 111 | - $options); | 110 | + ->request( |
| 111 | + $request->getMethod(), | ||
| 112 | + $request->getPath() ?: $this->serviceToPath($request->getService()), | ||
| 113 | + $options | ||
| 114 | + ); | ||
| 112 | }, function ($e) { | 115 | }, function ($e) { |
| 113 | return $e instanceof ConnectException; | 116 | return $e instanceof ConnectException; |
| 114 | }); | 117 | }); |
-
请 注册 或 登录 后发表评论