GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#6)
by
unknown
02:30
created

LuosimaoGateway   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 42
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 11 11 1
A buildEndpoint() 4 4 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
/*
4
 * This file is part of the overtrue/easy-sms.
5
 * (c) Jiajian Chan <[email protected]>
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
namespace Overtrue\EasySms\Gateways;
11
12
use Overtrue\EasySms\HasHttpRequest;
13
14
/**
15
 * Class LuosimaoGateway.
16
 */
17 View Code Duplication
class LuosimaoGateway extends Gateway
0 ignored issues
show
Duplication introduced by
This class 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
    use HasHttpRequest;
20
21
    const ENDPOINT_TEMPLATE = 'https://%s.luosimao.com/%s/%s.%s';
22
    const ENDPOINT_VERSION = 'v1';
23
    const ENDPOINT_FORMAT = 'json';
24
25
    /**
26
     * Send a short message.
27
     *
28
     * @param string|int $to
29
     * @param string     $message
30
     * @param array      $data
31
     *
32
     * @return mixed
33
     */
34
    public function send($to, $message, array $data = [])
35
    {
36
        $endpoint = $this->buildEndpoint('sms-api', 'send');
37
38
        return $this->post($endpoint, [
39
            'mobile' => $to,
40
            'message' => $message,
41
        ], [
42
            'Authorization' => 'Basic ' . base64_encode('api:key-' . $this->config->get('api_key')),
43
        ]);
44
    }
45
46
    /**
47
     * Build endpoint url.
48
     *
49
     * @param string $type
50
     * @param string $function
51
     *
52
     * @return string
53
     */
54
    protected function buildEndpoint($type, $function)
55
    {
56
        return sprintf(self::ENDPOINT_TEMPLATE, $type, self::ENDPOINT_VERSION, $function, self::ENDPOINT_FORMAT);
57
    }
58
}
59