optimize: 优化微信 ResponsePlugin 插件去除不必要的返回参数 (#996)

This commit is contained in:
yansongda 2024-06-10 22:01:39 +08:00 committed by GitHub
parent 66942f1db7
commit 3683c69c1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,9 @@
## TBD - v3.7.5
### optimized
- optimize: 优化微信 `ResponsePlugin` 插件去除不必要的返回参数(#996)
### deprecated
- deprecate: 微信 `StartPlugin` 改为使用 `yansongda/artful` 中的插件(#993)

View File

@ -5,14 +5,12 @@ declare(strict_types=1);
namespace Yansongda\Pay\Plugin\Wechat;
use Closure;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface;
use Yansongda\Artful\Contract\PluginInterface;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Artful\Logger;
use Yansongda\Artful\Rocket;
use Yansongda\Pay\Exception\Exception;
use Yansongda\Supports\Collection;
class ResponsePlugin implements PluginInterface
{
@ -26,7 +24,7 @@ class ResponsePlugin implements PluginInterface
Logger::debug('[Wechat][ResponsePlugin] 插件开始装载', ['rocket' => $rocket]);
$rocket->setDestination($this->validateResponse($rocket));
$this->validateResponse($rocket);
Logger::info('[Wechat][ResponsePlugin] 插件装载完毕', ['rocket' => $rocket]);
@ -36,7 +34,7 @@ class ResponsePlugin implements PluginInterface
/**
* @throws InvalidResponseException
*/
protected function validateResponse(Rocket $rocket): null|Collection|MessageInterface
protected function validateResponse(Rocket $rocket): void
{
$response = $rocket->getDestinationOrigin();
@ -44,7 +42,5 @@ class ResponsePlugin implements PluginInterface
&& ($response->getStatusCode() < 200 || $response->getStatusCode() >= 300)) {
throw new InvalidResponseException(Exception::RESPONSE_CODE_WRONG, '微信返回状态码异常,请检查参数是否错误', $rocket->getDestination());
}
return $rocket->getDestination();
}
}