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