Items   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDepartTypeCn() 0 14 2
1
<?php
2
/**
3
 * This file is part of the mucts.com.
4
 *
5
 * This source file is subject to the MIT license that is bundled
6
 * with this source code in the file LICENSE.
7
 *
8
 * @version 1.0
9
 * @author herry<[email protected]>
10
 * @copyright © 2020  MuCTS.com All Rights Reserved.
11
 */
12
13
namespace MuCTS\Sobot\Agents\QueryDepartments\Response;
14
15
16
use MuCTS\Sobot\Contracts\Response;
17
18
/**
19
 * Class Items
20
 * @property-read string $companyid 公司ID
21
 * @property-read string $departid 部门ID
22
 * @property-read string $depart_name 部门名称
23
 * @property-read string $depart_level 部门级别
24
 * @property-read string $depart_type 部门职能,1-在线,2-呼叫,3-电销,4-工单(部门职能可能有多个,多个以逗号分隔,例如:1,2,3)
25
 * @property-read string $depart_type_cn 部门职能
26
 * @property-read string $parentid 所属父级部门ID
27
 * @property-read Items[] $sub_department_list 子级部门信息
28
 * @package MuCTS\Sobot\Agents\QueryDepartments\Response
29
 */
30
class Items extends Response
31
{
32
    protected $sub_fields = ['sub_department_list'];
33
34
    /**
35
     * 部门职能
36
     * @return string
37
     */
38
    public function getDepartTypeCn()
39
    {
40
        $departType = $this->depart_type;
41
        $departType = explode(',', $departType);
42
        $departTypeCn = [
43
            1 => '在线',
44
            2 => '呼叫',
45
            3 => '电销',
46
            4 => '工单'
47
        ];
48
        foreach ($departType as &$type) {
49
            $type = $departTypeCn[$type] ?? '未知';
50
        }
51
        return implode(',', $departType);
52
    }
53
}