diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 0206cbc..53675d7 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -4,3 +4,10 @@ filter: checks: php: true + +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run diff --git a/src/Listener/KernelLogSubscriber.php b/src/Listener/KernelLogSubscriber.php index efc4b24..94c98e9 100644 --- a/src/Listener/KernelLogSubscriber.php +++ b/src/Listener/KernelLogSubscriber.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Yansongda\Pay\Listener; use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Yansongda\Pay\Contract\LoggerInterface; use Yansongda\Pay\Event\ApiRequested; use Yansongda\Pay\Event\ApiRequesting; use Yansongda\Pay\Event\MethodCalled; @@ -13,29 +12,10 @@ use Yansongda\Pay\Event\PayStarted; use Yansongda\Pay\Event\PayStarting; use Yansongda\Pay\Event\RequestReceived; use Yansongda\Pay\Event\SignFailed; -use Yansongda\Pay\Pay; +use Yansongda\Pay\Logger; class KernelLogSubscriber implements EventSubscriberInterface { - /** - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * Bootstrap. - * - * @author yansongda - * - * @throws \Yansongda\Pay\Exception\ContainerDependencyException - * @throws \Yansongda\Pay\Exception\ContainerException - * @throws \Yansongda\Pay\Exception\ServiceNotFoundException - */ - public function __construct() - { - $this->logger = Pay::get(LoggerInterface::class); - } - /** * Returns an array of event names this subscriber wants to listen to. * @@ -74,7 +54,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writePayStartingLog(PayStarting $event) { - $this->logger->debug("Starting To $event->driver", [$event->gateway, $event->params]); + Logger::debug("Starting To $event->driver", [$event->gateway, $event->params]); } /** @@ -84,7 +64,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writePayStartedLog(PayStarted $event) { - $this->logger->info( + Logger::info( "$event->driver $event->gateway Has Started", [$event->endpoint, $event->payload] ); @@ -97,7 +77,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writeApiRequestingLog(ApiRequesting $event) { - $this->logger->debug("Requesting To $event->driver Api", [$event->endpoint, $event->payload]); + Logger::debug("Requesting To $event->driver Api", [$event->endpoint, $event->payload]); } /** @@ -107,7 +87,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writeApiRequestedLog(ApiRequested $event) { - $this->logger->debug("Result Of $event->driver Api", $event->result); + Logger::debug("Result Of $event->driver Api", $event->result); } /** @@ -117,7 +97,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writeSignFailedLog(SignFailed $event) { - $this->logger->warning("$event->driver Sign Verify FAILED", $event->data); + Logger::warning("$event->driver Sign Verify FAILED", $event->data); } /** @@ -127,7 +107,7 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writeRequestReceivedLog(RequestReceived $event) { - $this->logger->info("Received $event->driver Request", $event->data); + Logger::info("Received $event->driver Request", $event->data); } /** @@ -137,6 +117,6 @@ class KernelLogSubscriber implements EventSubscriberInterface */ public function writeMethodCalledLog(MethodCalled $event) { - $this->logger->info("$event->driver $event->gateway Method Has Called", [$event->endpoint, $event->payload]); + Logger::info("$event->driver $event->gateway Method Has Called", [$event->endpoint, $event->payload]); } } diff --git a/src/Logger.php b/src/Logger.php index 2884b4c..bae5dff 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Yansongda\Pay; +use Throwable; use Yansongda\Pay\Contract\LoggerInterface; /** @@ -19,14 +20,13 @@ use Yansongda\Pay\Contract\LoggerInterface; */ class Logger { - /** - * @throws \Yansongda\Pay\Exception\ContainerDependencyException - * @throws \Yansongda\Pay\Exception\ContainerException - * @throws \Yansongda\Pay\Exception\ServiceNotFoundException - */ - public static function __callStatic(string $method, array $args) + public static function __callStatic(string $method, array $args): void { - $class = Pay::get(LoggerInterface::class); + try { + $class = Pay::get(LoggerInterface::class); + } catch (Throwable $e) { + return; + } forward_static_call_array([$class, $method], $args); } diff --git a/src/Plugin/Alipay/Fund/TransUniTransferPlugin.php b/src/Plugin/Alipay/Fund/TransUniTransferPlugin.php index fef36a1..b77ba25 100644 --- a/src/Plugin/Alipay/Fund/TransUniTransferPlugin.php +++ b/src/Plugin/Alipay/Fund/TransUniTransferPlugin.php @@ -5,22 +5,24 @@ declare(strict_types=1); namespace Yansongda\Pay\Plugin\Alipay\Fund; use Closure; -use Yansongda\Supports\Collection; +use Yansongda\Pay\Contract\PluginInterface; +use Yansongda\Pay\Rocket; -class TransUniTransferPlugin +class TransUniTransferPlugin implements PluginInterface { - public function apply(array $params, Collection $payload, Closure $next): Collection + public function assembly(Rocket $rocket, Closure $next): Rocket { - $payload = $payload->merge([ + $rocket->mergePayload([ 'method' => 'alipay.fund.trans.uni.transfer', - 'biz_content' => json_encode(array_merge( + 'biz_content' => array_merge( [ + 'biz_scene' => 'DIRECT_TRANSFER', 'product_code' => 'TRANS_ACCOUNT_NO_PWD', ], - $params - )), + $rocket->getParams(), + ), ]); - return $next($params, $payload); + return $next($rocket); } } diff --git a/src/Plugin/Alipay/Shortcut/TransferPlugin.php b/src/Plugin/Alipay/Shortcut/TransferPlugin.php deleted file mode 100644 index 54f567a..0000000 --- a/src/Plugin/Alipay/Shortcut/TransferPlugin.php +++ /dev/null @@ -1,17 +0,0 @@ -