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

CreatePlugin::getPartnerUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
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