Completed
Pull Request — master (#62)
by lan tian
02:30
created

UcpaasAgent::setResult()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 7
nc 2
nop 1
1
<?php
2
3
namespace Toplan\PhpSms;
4
5
/**
6
 * Class UcpaasAgent
7
 *
8
 * @property string $accountSid
9
 * @property string $accountToken
10
 * @property string $appId
11
 */
12
class UcpaasAgent extends Agent
13
{
14
    public function sendSms($to, $content, $tempId, array $data)
15
    {
16
        $this->sendTemplateSms($to, $tempId, $data);
17
    }
18
19 View Code Duplication
    public function sendTemplateSms($to, $tempId, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $config = [
22
            'accountsid' => $this->accountSid,
23
            'token'      => $this->accountToken,
24
        ];
25
        $ucpaas = new \Ucpaas($config);
26
        $response = $ucpaas->templateSMS($this->appId, $to, $tempId, implode(',', $data));
27
        $result = json_decode($response);
28
        $this->setResult($result);
29
    }
30
31 View Code Duplication
    public function voiceVerify($to, $code, $tempId, array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $config = [
34
            'accountsid' => $this->accountSid,
35
            'token'      => $this->accountToken,
36
        ];
37
        $ucpass = new \Ucpaas($config);
38
        $response = $ucpass->voiceCode($this->appId, $code, $to, $type = 'json');
39
        $result = json_decode($response);
40
        $this->result($result);
41
    }
42
43
    protected function setResult($result)
44
    {
45
        if (empty($result) || !is_object($result)) {
46
            $this->result(Agent::INFO, '请求失败');
47
48
            return;
49
        }
50
        $this->result(Agent::SUCCESS, $result->resp->respCode === '000000');
51
        $this->result(Agent::CODE, $result->resp->respCode);
52
        $this->result(Agent::INFO, $result->resp->respCode);
53
    }
54
55
    public function sendContentSms($to, $content)
56
    {
57
    }
58
}
59