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

YunPianAgent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 63.16 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 5
c 4
b 1
f 1
lcom 1
cbo 1
dl 24
loc 38
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A sendSms() 0 4 1
A sendContentSms() 9 9 1
A voiceVerify() 8 8 1
A setResult() 7 7 1
A sendTemplateSms() 0 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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