Agent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 8 1
A set() 0 8 1
A lists() 0 4 1
1
<?php
2
3
namespace EntWeChat\Agent;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Agent.
9
 */
10
class Agent extends AbstractAPI
11
{
12
    const API_GET = 'https://qyapi.weixin.qq.com/cgi-bin/agent/get';
13
    const API_SET = 'https://qyapi.weixin.qq.com/cgi-bin/agent/set';
14
    const API_LIST = 'https://qyapi.weixin.qq.com/cgi-bin/agent/list';
15
16
    /**
17
     * Fetch an agent by agent id.
18
     *
19
     * @param int $agentId
20
     *
21
     * @return \EntWeChat\Support\Collection
22
     */
23
    public function get($agentId)
24
    {
25
        $params = [
26
            'agentid' => $agentId,
27
        ];
28
29
        return $this->parseJSON('get', [self::API_GET, $params]);
30
    }
31
32
    /**
33
     * Set an agent by agent id.
34
     *
35
     * @param int   $agentId
36
     * @param array $agentInfo
37
     *
38
     * @return \EntWeChat\Support\Collection
39
     */
40
    public function set($agentId, array $agentInfo = [])
41
    {
42
        $params = array_merge($agentInfo, [
43
            'agentid' => $agentId,
44
        ]);
45
46
        return $this->parseJSON('json', [self::API_SET, $params]);
47
    }
48
49
    /**
50
     * List agents.
51
     *
52
     * @return \EntWeChat\Support\Collection
53
     */
54
    public function lists()
55
    {
56
        return $this->parseJSON('get', [self::API_LIST]);
57
    }
58
}
59