Completed
Push — master ( 32869d...8a9333 )
by Carlos
04:33 queued 30s
created

Client   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 59
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A sendNormal() 0 9 1
A sendGroup() 0 8 1
A info() 0 9 2
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\Payment\Redpack;
13
14
use EasyWeChat\Kernel\Support;
15
use EasyWeChat\Payment\Kernel\BaseClient;
16
17
/**
18
 * Class Client.
19
 *
20
 * @author tianyong90 <[email protected]>
21
 */
22
class Client extends BaseClient
23
{
24
    /**
25
     * Query redpack.
26
     *
27
     * @param mixed $params
28
     *
29
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
30
     *
31
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
32
     */
33 1
    public function info($mchBillno)
34
    {
35 1
        $params = is_array($mchBillno) ? $mchBillno : ['mch_billno' => $mchBillno];
36
        $base = [
37 1
            'appid' => $this->app['config']->app_id,
38 1
            'bill_type' => 'MCHT',
39
        ];
40
41 1
        return $this->safeRequest('mmpaymkttransfers/gethbinfo', array_merge($base, $params));
42
    }
43
44
    /**
45
     * Send normal redpack.
46
     *
47
     * @param array $params
48
     *
49
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
50
     *
51
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
52
     */
53 1
    public function sendNormal(array $params)
54
    {
55
        $base = [
56 1
            'total_num' => 1,
57 1
            'client_ip' => $params['client_ip'] ?? Support\get_server_ip(),
0 ignored issues
show
Bug introduced by
The function get_server_ip was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
            'client_ip' => $params['client_ip'] ?? /** @scrutinizer ignore-call */ Support\get_server_ip(),
Loading history...
58 1
            'wxappid' => $this->app['config']->app_id,
59
        ];
60
61 1
        return $this->safeRequest('mmpaymkttransfers/sendredpack', array_merge($base, $params));
62
    }
63
64
    /**
65
     * Send group redpack.
66
     *
67
     * @param array $params
68
     *
69
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
70
     *
71
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
72
     */
73 1
    public function sendGroup(array $params)
74
    {
75
        $base = [
76 1
            'amt_type' => 'ALL_RAND',
77 1
            'wxappid' => $this->app['config']->app_id,
78
        ];
79
80 1
        return $this->safeRequest('mmpaymkttransfers/sendgroupredpack', array_merge($base, $params));
81
    }
82
}
83