From 15fcb4707a6f2459ac12754d2c6b2502ff721041 Mon Sep 17 00:00:00 2001 From: yansongda Date: Mon, 1 Jan 2024 12:30:15 +0800 Subject: [PATCH] =?UTF-8?q?change(internal):=20=E5=B0=86=20`call()`=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BA=20`short?= =?UTF-8?q?cut()`=20(#914)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/Provider/AbstractProvider.php | 12 ++++++------ src/Provider/Alipay.php | 2 +- src/Provider/Unipay.php | 2 +- src/Provider/Wechat.php | 2 +- tests/Provider/AbstractProviderTest.php | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad25374e4..c2aef44fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - change(internal): DirectionInterface 方法由 `parse` 改为 `guide`(#896) - change(internal): 错误代码 const 命名规则统一(#902, #903, #906, #909) - change(internal): 调整 `ProviderInterface` 的返回参数,增加了 `Rocket` 返回(#909) +- change(internal): 将 `call()` 方法重命名为 `shortcut()`(#914) ## v3.5.3 diff --git a/src/Provider/AbstractProvider.php b/src/Provider/AbstractProvider.php index 7d0545c30..2a2ab1ad1 100644 --- a/src/Provider/AbstractProvider.php +++ b/src/Provider/AbstractProvider.php @@ -33,16 +33,16 @@ abstract class AbstractProvider implements ProviderInterface * @throws InvalidParamsException * @throws ServiceNotFoundException */ - public function call(string $plugin, array $params = []): null|Collection|MessageInterface|Rocket + public function shortcut(string $shortcut, array $params = []): null|Collection|MessageInterface|Rocket { - if (!class_exists($plugin) || !in_array(ShortcutInterface::class, class_implements($plugin))) { - throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_NOT_FOUND, "参数异常: [{$plugin}] 未实现 `ShortcutInterface`"); + if (!class_exists($shortcut) || !in_array(ShortcutInterface::class, class_implements($shortcut))) { + throw new InvalidParamsException(Exception::PARAMS_SHORTCUT_NOT_FOUND, "参数异常: [{$shortcut}] 未实现 `ShortcutInterface`"); } - /* @var ShortcutInterface $shortcut */ - $shortcut = Pay::get($plugin); + /* @var ShortcutInterface $shortcutInstance */ + $shortcutInstance = Pay::get($shortcut); - return $this->pay($shortcut->getPlugins($params), $params); + return $this->pay($shortcutInstance->getPlugins($params), $params); } /** diff --git a/src/Provider/Alipay.php b/src/Provider/Alipay.php index 58ce36dd3..f161284cd 100644 --- a/src/Provider/Alipay.php +++ b/src/Provider/Alipay.php @@ -52,7 +52,7 @@ public function __call(string $shortcut, array $params): null|Collection|Message { $plugin = '\\Yansongda\\Pay\\Shortcut\\Alipay\\'.Str::studly($shortcut).'Shortcut'; - return $this->call($plugin, ...$params); + return $this->shortcut($plugin, ...$params); } /** diff --git a/src/Provider/Unipay.php b/src/Provider/Unipay.php index 226315d8d..953e47851 100644 --- a/src/Provider/Unipay.php +++ b/src/Provider/Unipay.php @@ -46,7 +46,7 @@ public function __call(string $shortcut, array $params): null|Collection|Message { $plugin = '\\Yansongda\\Pay\\Shortcut\\Unipay\\'.Str::studly($shortcut).'Shortcut'; - return $this->call($plugin, ...$params); + return $this->shortcut($plugin, ...$params); } /** diff --git a/src/Provider/Wechat.php b/src/Provider/Wechat.php index fc2658fad..ac31719c4 100644 --- a/src/Provider/Wechat.php +++ b/src/Provider/Wechat.php @@ -59,7 +59,7 @@ public function __call(string $shortcut, array $params): null|Collection|Message { $plugin = '\\Yansongda\\Pay\\Shortcut\\Wechat\\'.Str::studly($shortcut).'Shortcut'; - return $this->call($plugin, ...$params); + return $this->shortcut($plugin, ...$params); } /** diff --git a/tests/Provider/AbstractProviderTest.php b/tests/Provider/AbstractProviderTest.php index 251153750..ebf38f3fd 100644 --- a/tests/Provider/AbstractProviderTest.php +++ b/tests/Provider/AbstractProviderTest.php @@ -123,7 +123,7 @@ public function testIgniteWrongHttpClient() public function testNoCommonPlugins() { $provider = new Foo2ProviderStub(); - $result = $provider->call(FooShortcut::class, ['_no_common_plugins' => true]); + $result = $provider->shortcut(FooShortcut::class, ['_no_common_plugins' => true]); self::assertInstanceOf(ResponseInterface::class, $result); }