Passed
Push — master ( c74e83...4330b5 )
by test
02:39
created

GroupClient::delGroup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace EasyIM\TencentIM\Sns;
4
5
use EasyIM\Kernel\BaseClient;
6
use EasyIM\Kernel\Support\Arr;
7
8
/**
9
 * Class GroupClient
10
 *
11
 * @package EasyIM\TencentIM\Sns
12
 * @author  longing <[email protected]>
13
 */
14
class GroupClient extends BaseClient
15
{
16
    /**
17
     * Add group.
18
     *
19
     * @param string     $fromAccount
20
     * @param array      $groupName
21
     * @param array|null $toAccount
22
     *
23
     * @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
24
     * @throws \EasyIM\Kernel\Exceptions\InvalidConfigException
25
     * @throws \GuzzleHttp\Exception\GuzzleException
26
     */
27
    public function addGroup(string $fromAccount, array $groupName, array $toAccount = null)
28
    {
29
        $params = [
30
            'From_Account' => $fromAccount,
31
            'GroupName' => $groupName
32
        ];
33
34
        Arr::setNotNullValue($params, 'To_Account', $toAccount);
35
36
        return $this->httpPostJson('sns/group_add', $params);
37
    }
38
39
40
    /**
41
     * Delete group.
42
     *
43
     * @param string $fromAccount
44
     * @param array  $groupName
45
     *
46
     * @return array|\EasyIM\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
47
     * @throws \EasyIM\Kernel\Exceptions\InvalidConfigException
48
     * @throws \GuzzleHttp\Exception\GuzzleException
49
     */
50
    public function delGroup(string $fromAccount, array $groupName)
51
    {
52
        $params = [
53
            'From_Account' => $fromAccount,
54
            'GroupName' => $groupName
55
        ];
56
57
        return $this->httpPostJson('sns/group_delete', $params);
58
    }
59
}
60