Passed
Pull Request — master (#461)
by Songda
02:16
created

GeneralPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 7
c 2
b 1
f 0
dl 0
loc 14
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Alipay;
6
7
use Closure;
8
use Yansongda\Pay\Contract\PluginInterface;
9
use Yansongda\Pay\Logger;
10
use Yansongda\Pay\Rocket;
11
12
abstract class GeneralPlugin implements PluginInterface
13
{
14
    public function assembly(Rocket $rocket, Closure $next): Rocket
15
    {
16
        Logger::info('[alipay][GeneralPlugin] 通用插件开始装载', ['rocket' => $rocket]);
17
18
        $this->doSomethingBefore($rocket);
19
20
        $rocket->mergePayload([
21
            'method' => $this->getMethod(),
22
            'biz_content' => $rocket->getParams(),
23
        ]);
24
25
        Logger::info('[alipay][GeneralPlugin] 通用插件装载完毕', ['rocket' => $rocket]);
26
27
        return $next($rocket);
28
    }
29
30
    protected function doSomethingBefore(Rocket $rocket): void
31
    {
32
    }
33
34
    abstract protected function getMethod(): string;
35
}
36