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

GeneralPlugin   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A assembly() 0 14 1
A doSomethingBefore() 0 2 1
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