Request::getSign()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
}