Sms   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 45
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getParams() 0 9 2
A getMethod() 0 3 1
A __construct() 0 9 1
1
<?php
2
3
namespace Vicens\Alidayu\Request;
4
5
/**
6
 * 发送短信通知类
7
 * @link https://api.alidayu.com/docs/api.htm?apiId=25450
8
 * @method $this|string recNum(string | null $recNum = null)
9
 * @method $this|string smsTemplateCode(string | null $smsTemplateCode = null)
10
 * @method $this|string smsFreeSignName(string | null $smsFreeSignName = null)
11
 * @method $this|array smsParam(array | null $smsParam = null)
12
 * @method $this|string extend(string | null $extend = null)
13
 */
14
class Sms extends AbstractRequest
15
{
16
17
    /**
18
     * Sms constructor.
19
     * @param string $recNum 接收方手机号
20
     * @param string $smsTemplateCode 模板ID
21
     * @param string $smsFreeSignName 签名
22
     * @param array $smsParam 模板变量
23
     * @param string $extend 回传参数
24
     */
25
    public function __construct($recNum, $smsTemplateCode, $smsFreeSignName, array $smsParam = [], $extend = '')
26
    {
27
        $this->setParams([
28
            'sms_type' => 'normal',
29
            'rec_num' => $recNum,
30
            'sms_template_code' => $smsTemplateCode,
31
            'sms_free_sign_name' => $smsFreeSignName,
32
            'sms_param' => $smsParam,
33
            'extend' => $extend
34
        ]);
35
    }
36
37
    /**
38
     * 返回接口参数
39
     * @return array
40
     */
41
    public function getParams()
42
    {
43
        $params = parent::getParams();
44
45
        if (is_array($params['sms_param'])) {
46
            $params['sms_param'] = json_encode($params['sms_param']);
47
        }
48
49
        return $params;
50
    }
51
52
    /**
53
     * 返回接口名
54
     * @return string
55
     */
56
    public function getMethod()
57
    {
58
        return 'alibaba.aliqin.fc.sms.num.send';
59
    }
60
}
61
62