Passed
Pull Request — master (#503)
by Songda
02:02
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
        $payload = $rocket->getPayload();
22
23
        $extra = [
24
            'appid' => $config->get('mp_app_id'),
25
        ];
26
27
        if (Pay::MODE_SERVICE == $config->get('mode') && !$payload->has('sub_mchid')) {
28
            $extra = [
29
                'sub_mchid' => $config->get('sub_mch_id', ''),
30
            ];
31
        }
32
33
        $rocket->mergePayload($extra);
34
    }
35
36
    protected function getUri(Rocket $rocket): string
37
    {
38
        return 'v3/transfer/batches';
39
    }
40
41
    protected function getPartnerUri(Rocket $rocket): string
42
    {
43
        return 'v3/partner-transfer/batches';
44
    }
45
}
46