Request   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 47
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreateTime() 0 6 2
A getSign() 0 3 1
A toArray() 0 6 1
1
<?php
2
3
4
namespace MuCTS\Sobot\Token\Token;
5
6
7
use \MuCTS\Sobot\Contracts\Request as RequestContract;
8
9
class Request extends RequestContract
10
{
11
    private $createTime;
12
13
    /**
14
     * token创建时间
15
     *
16
     * @return int
17
     * @author herry.yao <[email protected]>
18
     * @version 1.2.2
19
     * @date 2020-08-05
20
     */
21
    public function getCreateTime()
22
    {
23
        if (is_null($this->createTime)) {
24
            $this->createTime = time();
25
        }
26
        return $this->createTime;
27
    }
28
29
    /**
30
     * 获取签名
31
     *
32
     * @return string
33
     * @author herry.yao <[email protected]>
34
     * @version 1.2.2
35
     * @date 2020-08-05
36
     */
37
    protected function getSign()
38
    {
39
        return md5($this->getAppId() . $this->getCreateTime() . $this->getAppKey());
40
    }
41
42
    /**
43
     * 返回请求数据
44
     *
45
     * @return array
46
     * @author herry.yao <[email protected]>
47
     * @version 1.2.2
48
     * @date 2020-08-05
49
     */
50
    public function toArray(): array
51
    {
52
        return [
53
            'appid'       => $this->getAppId(),
54
            'create_time' => $this->getCreateTime(),
55
            'sign'        => $this->getSign()
56
        ];
57
    }
58
}