Passed
Push — master ( c581fb...215d5f )
by Songda
02:50 queued 45s
created

CreatePlugin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 3 1
A getPartnerUri() 0 3 1
A doSomething() 0 15 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
6
7
use Yansongda\Pay\Pay;
8
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
9
use Yansongda\Pay\Rocket;
10
11
class CreatePlugin extends GeneralPlugin
12
{
13
    /**
14
     * @throws \Yansongda\Pay\Exception\ContainerDependencyException
15
     * @throws \Yansongda\Pay\Exception\ContainerException
16
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
17
     */
18
    protected function doSomething(Rocket $rocket): void
19
    {
20
        $config = get_wechat_config($rocket->getParams());
21
22
        $extra = [
23
            'appid' => $config->get('mp_app_id'),
24
        ];
25
26
        if (Pay::MODE_SERVICE == $config->get('mode')) {
27
            $extra = [
28
                'sub_mchid' => $config->get('sub_mch_id', ''),
29
            ];
30
        }
31
32
        $rocket->mergePayload($extra);
33
    }
34
35
    protected function getUri(Rocket $rocket): string
36
    {
37
        return 'v3/transfer/batches';
38
    }
39
40
    protected function getPartnerUri(Rocket $rocket): string
41
    {
42
        return 'v3/partner-transfer/batches';
43
    }
44
}
45