Staff   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 13.79 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 8
loc 58
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A lists() 8 8 1
A message() 0 6 1
A send() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace EntWeChat\Staff;
4
5
use EntWeChat\Core\AbstractAPI;
6
7
/**
8
 * Class Staff.
9
 */
10
class Staff extends AbstractAPI
11
{
12
    const API_LISTS = 'https://qyapi.weixin.qq.com/cgi-bin/kf/list';
13
    const API_MESSAGE_SEND = 'https://qyapi.weixin.qq.com/cgi-bin/kf/send';
14
15
    //用户类型
16
    const USER_TYPE_STAFF = 'kf';      // 客服
17
    const USER_TYPE_USERID = 'userid';  // 客户UserId
18
    const USER_TYPE_OPENID = 'openid';  // 客户OpenId
19
20
    //客服类型
21
    const STAFF_TYPE_INTERNAL = 'internal';  // 内部
22
    const STAFF_TYPE_EXTERNAL = 'external';  // 外部
23
24
    /**
25
     * List all staffs.
26
     *
27
     * @param string|null $type
28
     *
29
     * @return \EntWeChat\Support\Collection
30
     */
31 View Code Duplication
    public function lists($type = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $params = [
34
            'type' => $type,
35
        ];
36
37
        return $this->parseJSON('get', [self::API_LISTS, $params]);
38
    }
39
40
    /**
41
     * Get message builder.
42
     *
43
     * @param \EntWeChat\Message\AbstractMessage|string $message
44
     *
45
     * @throws \EntWeChat\Core\Exceptions\InvalidArgumentException
46
     *
47
     * @return \EntWeChat\Staff\MessageBuilder
48
     */
49
    public function message($message)
50
    {
51
        $messageBuilder = new MessageBuilder($this);
52
53
        return $messageBuilder->message($message);
54
    }
55
56
    /**
57
     * Send a message.
58
     *
59
     * @param string|array $message
60
     *
61
     * @return \EntWeChat\Support\Collection
62
     */
63
    public function send($message)
64
    {
65
        return $this->parseJSON('json', [self::API_MESSAGE_SEND, $message]);
66
    }
67
}
68