Skip to content

Commit

Permalink
change(internal): 将 call() 方法重命名为 shortcut() (#914)
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda authored Jan 1, 2024
1 parent 9713c08 commit 15fcb47
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions src/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Alipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Unipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Provider/Wechat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Provider/AbstractProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 15fcb47

Please sign in to comment.