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 (#121)
by monster
02:55
created

MwGateway::send()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3.4977

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 13
cts 21
cp 0.619
rs 9.488
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 3.4977
1
<?php
2
3
/*
4
 * This file is part of the overtrue/easy-sms.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\EasySms\Gateways;
13
14
use Overtrue\EasySms\Contracts\MessageInterface;
15
use Overtrue\EasySms\Contracts\PhoneNumberInterface;
16
use Overtrue\EasySms\Support\Config;
17
use Overtrue\EasySms\Traits\HasHttpRequest;
18
19
/**
20
 * Class MwGateway.
21
 *
22
 * @see hhttp://con.monyun.cn:9960/developer_Center/index.html?htmlURL1=API&htmlURL2=APIone&iden=1334141369429928360
23
 */
24
class MwGateway extends Gateway
25
{
26
    use HasHttpRequest;
27
28
    const ENDPOINT_TEMPLATE = 'http://61.145.229.28:8806/MWGate/wmgw.asmx/MongateSendSubmit';
29
30
    /**
31
     * @param \Overtrue\EasySms\Contracts\PhoneNumberInterface $to
32
     * @param \Overtrue\EasySms\Contracts\MessageInterface     $message
33
     * @param \Overtrue\EasySms\Support\Config                 $config
34
     *
35
     * @return array
36
     */
37 1
    public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config)
38
    {
39
        $params = [
40 1
            'query' => ['userId' => $config->get('userId'),
41 1
                    'password' => $config->get('password'),
42 1
                    'pszMobis' => $to->getUniversalNumber(),
43 1
                    'pszMsg' => $message->getContent($this),
44 1
                    'iMobiCount' => 1,
45 1
                    'pszSubPort' => $config->get('pszSubPort'),
46 1
                ],
47 1
        ];
48 1
        $result = $this->request('get', self::ENDPOINT_TEMPLATE, $params);
49 1
        $temp = [];
50 1
        if (isset($result['code'])) {
51 1
            return $result;
52
        }
53
        if (abs(intval($result[0])) > 100000) {
54
            $temp['code'] = 1;
55
            $temp['msg'] = 'success';
56
        } else {
57
            $temp['code'] = -1;
58
            $temp['msg'] = 'error';
59
        }
60
        $temp['real_code'] = $result[0];
61
62
        return $temp;
63
    }
64
}
65