CreatePlugin   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

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