Passed
Pull Request — master (#894)
by Songda
01:58
created

PayPlugin   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 10
c 1
b 0
f 0
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A assembly() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay\Pay\App;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Direction\ResponseDirection;
10
use Yansongda\Pay\Exception\ContainerException;
11
use Yansongda\Pay\Exception\ServiceNotFoundException;
12
use Yansongda\Pay\Logger;
13
use Yansongda\Pay\Rocket;
14
use Yansongda\Pay\Traits\SupportServiceProviderTrait;
15
16
/**
17
 * @see https://opendocs.alipay.com/open/cd12c885_alipay.trade.app.pay?pathHash=c0e35284&ref=api&scene=20
18
 */
19
class PayPlugin implements PluginInterface
20
{
21
    use SupportServiceProviderTrait;
22
23
    /**
24
     * @throws ContainerException
25
     * @throws ServiceNotFoundException
26
     */
27
    public function assembly(Rocket $rocket, Closure $next): Rocket
28
    {
29
        Logger::debug('[Alipay][Pay][App][PayPlugin] 插件开始装载', ['rocket' => $rocket]);
30
31
        $this->loadAlipayServiceProvider($rocket);
32
33
        $rocket->setDirection(ResponseDirection::class)
34
            ->mergePayload([
35
                'method' => 'alipay.trade.app.pay',
36
                'biz_content' => $rocket->getParams(),
37
            ]);
38
39
        Logger::info('[Alipay][Pay][App][PayPlugin] 插件装载完毕', ['rocket' => $rocket]);
40
41
        return $next($rocket);
42
    }
43
}
44