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

StartPlugin::assembly()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 17
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 25
rs 9.7
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
use Yansongda\Pay\Exception\ContainerException;
0 ignored issues
show
Bug introduced by
The type Yansongda\Pay\Exception\ContainerException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Yansongda\Pay\Exception\InvalidConfigException;
0 ignored issues
show
Bug introduced by
The type Yansongda\Pay\Exception\InvalidConfigException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Yansongda\Pay\Exception\ServiceNotFoundException;
0 ignored issues
show
Bug introduced by
The type Yansongda\Pay\Exception\ServiceNotFoundException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Yansongda\Supports\Str;
16
17
use function Yansongda\Pay\get_provider_config;
18
19
class StartPlugin implements PluginInterface
20
{
21
    /**
22
     * @throws ContainerException
23
     * @throws ServiceNotFoundException
24
     * @throws InvalidConfigException
25
     */
26
    public function assembly(Rocket $rocket, Closure $next): Rocket
27
    {
28
        Logger::info('[epay][StartPlugin] 插件开始装载', ['rocket' => $rocket]);
29
30
        $params = $rocket->getParams();
31
        $config = get_provider_config('epay', $params);
32
33
        $rocket->setPacker(QueryPacker::class)->mergePayload(array_merge(
34
            $params,
35
            [
36
                'createData' => date('Ymd'),
37
                'createTime' => date('His'),
38
                'bizDate' => date('Ymd'),
39
                'msgId' => Str::uuidV4(),
40
                'svrCode' => $config['svr_code'] ?? '',
41
                'partnerId' => $config['partner_id'] ?? '',
42
                'channelNo' => 'm',
43
                'publicKeyCode' => $config['public_key_code'] ?? '',
44
                'version' => 'v1.0.0',
45
                'charset' => 'utf-8',
46
            ]
47
        ));
48
        Logger::info('[epay][StartPlugin] 插件装载完毕', ['rocket' => $rocket]);
49
50
        return $next($rocket);
51
    }
52
}
53