Completed
Push — master ( 13cabb...9cf391 )
by lan tian
6s
created

YunPianAgent::setResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Toplan\PhpSms;
4
5
/**
6
 * Class YunPianAgent
7
 *
8
 * @property string $apikey
9
 */
10
class YunPianAgent extends Agent
11
{
12
    public function sendSms($to, $content, $tempId, array $data)
13
    {
14
        $this->sendContentSms($to, $content);
15
    }
16
17 View Code Duplication
    public function sendContentSms($to, $content)
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...
18
    {
19
        $url = 'http://yunpian.com/v1/sms/send.json';
20
        $apikey = $this->apikey;
21
        $content = urlencode("$content");
22
        $postString = "apikey=$apikey&text=$content&mobile=$to";
23
        $response = $this->sockPost($url, $postString);
24
        $this->setResult($response);
25
    }
26
27 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...
28
    {
29
        $url = 'http://voice.yunpian.com/v1/voice/send.json';
30
        $apikey = $this->apikey;
31
        $postString = "apikey=$apikey&code=$code&mobile=$to";
32
        $response = $this->sockPost($url, $postString);
33
        $this->setResult($response);
34
    }
35
36 View Code Duplication
    protected function setResult($result)
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...
37
    {
38
        $this->result(Agent::INFO, $result);
39
        $result = json_decode($result, true);
40
        $this->result(Agent::SUCCESS, $result['code'] === 0);
41
        $this->result(Agent::CODE, $result['code']);
42
    }
43
44
    public function sendTemplateSms($to, $tempId, array $data)
45
    {
46
    }
47
}
48