Passed
Pull Request — master (#1002)
by
unknown
02:12
created

GeneralPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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