Passed
Pull Request — master (#480)
by Songda
02:01
created

QueryMerchantConfigsPlugin::getMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing;
6
7
use Yansongda\Pay\Exception\Exception;
8
use Yansongda\Pay\Exception\InvalidParamsException;
9
use Yansongda\Pay\Pay;
10
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
11
use Yansongda\Pay\Rocket;
12
13
class QueryMerchantConfigsPlugin extends GeneralPlugin
14
{
15
    protected function getMethod(): string
16
    {
17
        return 'GET';
18
    }
19
20
    protected function doSomething(Rocket $rocket): void
21
    {
22
        $rocket->setPayload(null);
23
    }
24
25
    /**
26
     * @throws \Yansongda\Pay\Exception\ContainerDependencyException
27
     * @throws \Yansongda\Pay\Exception\ContainerException
28
     * @throws \Yansongda\Pay\Exception\InvalidParamsException
29
     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
30
     */
31
    protected function getUri(Rocket $rocket): string
32
    {
33
        $config = get_wechat_config($rocket->getParams());
34
        $payload = $rocket->getPayload();
35
36
        if (Pay::MODE_SERVICE !== $config->get('mode', Pay::MODE_NORMAL)) {
37
            throw new InvalidParamsException(Exception::METHOD_NOT_SUPPORTED);
38
        }
39
40
        return 'v3/profitsharing/merchant-configs/'.
41
            $payload->get('sub_mchid', $config->get('sub_mch_id', ''));
42
    }
43
}
44