Passed
Pull Request — master (#501)
by Songda
04:17 queued 02:13
created

QueryDetailReceiptPlugin   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 7
c 1
b 0
f 0
dl 0
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 3 1
A getMethod() 0 3 1
A doSomething() 0 9 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yansongda\Pay\Plugin\Wechat\Fund\Transfer;
6
7
use Yansongda\Pay\Exception\Exception;
8
use Yansongda\Pay\Exception\InvalidParamsException;
9
use Yansongda\Pay\Plugin\Wechat\GeneralPlugin;
10
use Yansongda\Pay\Rocket;
11
12
class QueryDetailReceiptPlugin extends GeneralPlugin
13
{
14
    protected function getMethod(): string
15
    {
16
        return 'GET';
17
    }
18
19
    /**
20
     * @throws \Yansongda\Pay\Exception\InvalidParamsException
21
     */
22
    protected function doSomething(Rocket $rocket): void
23
    {
24
        $payload = $rocket->getPayload();
25
26
        if (is_null($payload->get('out_detail_no')) || is_null($payload->get('accept_type'))) {
27
            throw new InvalidParamsException(Exception::MISSING_NECESSARY_PARAMS);
28
        }
29
30
        $rocket->setPayload(null);
31
    }
32
33
    protected function getUri(Rocket $rocket): string
34
    {
35
        return 'v3/transfer-detail/electronic-receipts?'.$rocket->getPayload()->query();
36
    }
37
}
38