Passed
Push — master ( 7fd1cc...deadb5 )
by Songda
02:28 queued 25s
created

QueryMerchantConfigsPlugin   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 0 3 1
A doSomething() 0 3 1
A getUri() 0 11 2
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