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::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 3
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