Passed
Pull Request — master (#1388)
by
unknown
03:12
created

Client::getBasicInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\OpenPlatform\Authorizer\MiniProgram\Setting;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author ClouderSky <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * 获取账号基本信息.
25
     */
26
    public function getBasicInfo()
27
    {
28
        return $this->httpPostJson('cgi-bin/account/getaccountbasicinfo');
29
    }
30
31
    /**
32
     * 修改头像.
33
     *
34
     * @param string $media_id 头像素材media_id
35
     * @param int    $left     剪裁框左上角x坐标(取值范围:[0, 1])
36
     * @param int    $top      剪裁框左上角y坐标(取值范围:[0, 1])
37
     * @param int    $right    剪裁框右下角x坐标(取值范围:[0, 1])
38
     * @param int    $bottom   剪裁框右下角y坐标(取值范围:[0, 1])
39
     */
40
    public function modifyHeadImage(
41
        string $media_id,
42
        float $left = 0,
43
        float $top = 0,
44
        float $right = 1,
45
        float $bottom = 1
46
    ) {
47
        $params = [
48
            'head_img_media_id' => $media_id,
49
            'x1' => $left, 'y1' => $top, 'x2' => $right, 'y2' => $bottom,
50
        ];
51
52
        return $this->httpPostJson('cgi-bin/account/modifyheadimage', $params);
53
    }
54
55
    /**
56
     * 修改功能介绍.
57
     *
58
     * @param string $signature 功能介绍(简介)
59
     */
60
    public function modifySignature($signature)
61
    {
62
        $params = ['signature' => $signature];
63
64
        return $this->httpPostJson('cgi-bin/account/modifysignature', $params);
65
    }
66
67
    /**
68
     * 获取账号可以设置的所有类目.
69
     */
70
    public function getAllCategories()
71
    {
72
        return $this->httpPostJson('cgi-bin/wxopen/getallcategories');
73
    }
74
75
    /**
76
     * 添加类目.
77
     *
78
     * @param array $categories 类目数组
79
     */
80
    public function addCategory(array $categories)
81
    {
82
        return $this->httpPostJson('cgi-bin/wxopen/addcategory', $categories);
83
    }
84
85
    /**
86
     * 删除类目.
87
     *
88
     * @param int $first_id  一级类目ID
89
     * @param int $second_id 二级类目ID
90
     */
91
    public function deleteCategory(int $first_id, int $second_id)
92
    {
93
        $params = ['first' => $first_id, 'second' => $second_id];
94
95
        return $this->httpPostJson('cgi-bin/wxopen/deletecategory', $params);
96
    }
97
98
    /**
99
     * 获取账号已经设置的所有类目.
100
     */
101
    public function getCategory()
102
    {
103
        return $this->httpPostJson('cgi-bin/wxopen/getcategory');
104
    }
105
106
    /**
107
     * 修改类目.
108
     *
109
     * @param array $category 单个类目
110
     */
111
    public function modifyCategory(array $category)
112
    {
113
        return $this->httpPostJson('cgi-bin/wxopen/modifycategory', $category);
114
    }
115
116
    /**
117
     * 小程序名称设置及改名.
118
     *
119
     * @param string $nickname   昵称
120
     * @param string $idcard     身份证照片素材ID
121
     * @param string $license    组织机构代码证或营业执照素材ID
122
     * @param string $stuff_list 其他证明材料素材ID
123
     */
124
    public function setNickname(
125
        string $nickname,
126
        string $idcard = '',
127
        string $license = '',
128
        array $stuff_list = []
129
    ) {
130
        $params = [
131
            'nick_name' => $nickname,
132
            'id_card' => $idcard,
133
            'license' => $license,
134
        ];
135
136
        for ($i = 0; $i < \count($stuff_list); ++$i) {
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function count() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
137
            $params['naming_other_stuff_'.($i + 1)] = $stuff_list[$i];
138
        }
139
140
        return $this->httpPostJson('wxa/setnickname', $params);
141
    }
142
143
    /**
144
     * 小程序改名审核状态查询.
145
     *
146
     * @param int $audit_id 审核单id
147
     */
148
    public function queryNickname($audit_id)
149
    {
150
        $params = ['audit_id' => $audit_id];
151
152
        return $this->httpPostJson('wxa/api_wxa_querynickname', $params);
153
    }
154
155
    /**
156
     * 微信认证名称检测.
157
     *
158
     * @param string $nickname 名称(昵称)
159
     */
160
    public function checkWxVerifyNickname($nickname)
161
    {
162
        $params = ['nick_name' => $nickname];
163
164
        return $this->httpPostJson(
165
            'cgi-bin/wxverify/checkwxverifynickname', $params);
166
    }
167
}
168