Completed
Push — master ( 6c98ed...eea45a )
by duan
03:01 queued 01:55
created

Base   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
eloc 94
dl 0
loc 179
ccs 4
cts 16
cp 0.25
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A secret() 0 4 1
A version() 0 4 1
A init() 0 6 2
A url() 0 4 1
A key() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: yiranzai
5
 * Date: 19-3-22
6
 * Time: 下午2:19
7
 */
8
9
namespace Yiranzai\Byrobot\Traits;
10
11
/**
12
 * Trait Base
13
 * @package Yiranzai\Byrobot\Traits
14
 */
15
trait Base
16
{
17
    /**
18
     * @var string
19
     */
20
    private static $appKey;
21
    /**
22
     * @var string
23
     */
24
    private static $appSecret;
25
    /**
26
     * 接口域名
27
     * @var string
28
     */
29
    private static $baseUrl = 'https://api.byrobot.cn';
30
    /**
31
     * 接口版本
32
     * @var string
33
     */
34
    private static $apiVersion = 'v1';
35
36
    /**
37
     * @var \Yiranzai\Byrobot\Byrobot
38
     */
39
    private static $robot;
40
41
    /**
42
     * @var array
43
     */
44
    public static $url = [
45
        'getCompanys'           => [
46
            'url'    => '/openapi/{apiVersion}/company/getCompanys',
47
            'method' => 'GET',
48
            'desc'   => '获取绑定公司列表接口',
49
        ],
50
        'getPhones'             => [
51
            'url'    => '/openapi/{apiVersion}/company/getPhones',
52
            'method' => 'GET',
53
            'desc'   => '获取公司的主叫电话列表接口',
54
        ],
55
        'getRobots'             => [
56
            'url'    => '/openapi/{apiVersion}/company/getRobots',
57
            'method' => 'GET',
58
            'desc'   => '获取公司的机器人话术列表接口',
59
        ],
60
        'addBlackList'          => [
61
            'url'    => '/openapi/{apiVersion}/company/addBlackList',
62
            'method' => 'POST',
63
            'desc'   => '添加单个黑名单到公司默认黑名单组接口',
64
        ],
65
        'statistics'            => [
66
            'url'    => '/openapi/{apiVersion}/company/seat/statistics',
67
            'method' => 'GET',
68
            'desc'   => '获取公司AI坐席概况接口',
69
        ],
70
        'createTask'            => [
71
            'url'    => '/openapi/{apiVersion}/task/createTask',
72
            'method' => 'POST',
73
            'desc'   => '创建任务接口',
74
        ],
75
        'start'                 => [
76
            'url'    => '/openapi/{apiVersion}/task/start',
77
            'method' => 'POST',
78
            'desc'   => '启动任务接口',
79
        ],
80
        'pause'                 => [
81
            'url'    => '/openapi/{apiVersion}/task/pause',
82
            'method' => 'POST',
83
            'desc'   => '暂停任务接口',
84
        ],
85
        'stop'                  => [
86
            'url'    => '/openapi/{apiVersion}/task/stop',
87
            'method' => 'POST',
88
            'desc'   => '停止任务接口',
89
        ],
90
        'delete'                => [
91
            'url'    => '/openapi/{apiVersion}/task/delete',
92
            'method' => 'POST',
93
            'desc'   => '删除任务',
94
        ],
95
        'importTaskCustomer'    => [
96
            'url'    => '/openapi/{apiVersion}/task/importTaskCustomer',
97
            'method' => 'POST',
98
            'desc'   => '向任务中导入客户接口',
99
        ],
100
        'update'                => [
101
            'url'    => '/openapi/{apiVersion}/task/update',
102
            'method' => 'POST',
103
            'desc'   => '修改任务',
104
        ],
105
        'call'                  => [
106
            'url'    => '/openapi/{apiVersion}/task/call',
107
            'method' => 'POST',
108
            'desc'   => '单次电话外呼',
109
        ],
110
        'singleCallByMobile'    => [
111
            'url'    => '/openapi/{apiVersion}/task/singleCallByMobile',
112
            'method' => 'POST',
113
            'desc'   => '根据手机号进行单次电话外呼',
114
        ],
115
        'getTasks'              => [
116
            'url'    => '/openapi/{apiVersion}/task/getTasks',
117
            'method' => 'GET',
118
            'desc'   => '获取任务列表接口',
119
        ],
120
        'getTaskDetail'         => [
121
            'url'    => '/openapi/{apiVersion}/task/getTaskDetail',
122
            'method' => 'GET',
123
            'desc'   => '获取任务详情接口',
124
        ],
125
        'queryDoneTaskPhones'   => [
126
            'url'    => '/openapi/{apiVersion}/task/queryDoneTaskPhones',
127
            'method' => 'POST',
128
            'desc'   => '获取已经完成任务电话号码接口',
129
        ],
130
        'notDialedCustomerList' => [
131
            'url'    => '/openapi/{apiVersion}/task/notDialedCustomerList',
132
            'method' => 'POST',
133
            'desc'   => '获取任务未开始的电话列表',
134
        ],
135
        'phoneLogInfo'          => [
136
            'url'    => '/openapi/{apiVersion}/task/phoneLogInfo',
137
            'method' => 'GET',
138
            'desc'   => '获取一个通话的详情接口',
139
        ],
140
    ];
141
142
    /**
143
     * @param $key
144
     * @return $this
145
     */
146
    public function key($key): self
147
    {
148
        self::$appKey = $key;
149
        return $this;
150
    }
151
152
    /**
153
     * @param $secret
154
     * @return $this
155
     */
156
    public function secret($secret): self
157
    {
158
        self::$appSecret = $secret;
159
        return $this;
160
    }
161
162
    /**
163
     * @param $version
164
     * @return $this
165
     */
166
    public function version($version): self
167
    {
168
        self::$apiVersion = $version;
169
        return $this;
170
    }
171
172
    /**
173
     * @param $url
174
     * @return $this
175
     */
176
    public function url($url): self
177
    {
178
        self::$baseUrl = $url;
179
        return $this;
180
    }
181
182
    /**
183
     * 获取百应机器人实例
184
     *
185
     * @param array $config
186
     * @return \Yiranzai\Byrobot\Byrobot
187
     */
188 15
    public static function init(array $config = []): \Yiranzai\Byrobot\Byrobot
189
    {
190 15
        if (null === static::$robot) {
0 ignored issues
show
Bug introduced by
Since $robot is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $robot to at least protected.
Loading history...
191 3
            static::$robot = new static($config);
0 ignored issues
show
Unused Code introduced by
The call to Yiranzai\Byrobot\Traits\Base::__construct() has too many arguments starting with $config. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

191
            static::$robot = /** @scrutinizer ignore-call */ new static($config);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
192
        }
193 15
        return static::$robot;
194
    }
195
}
196