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 (#5)
by t
63:46
created

Api   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
c 1
b 0
f 0
dl 0
loc 48
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A ip() 0 14 2
A mobile() 0 16 2
1
<?php
2
/**
3
 * Class Api
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
namespace icy2003\php\iapis;
10
11
use icy2003\php\I;
12
use icy2003\php\ihelpers\Arrays;
13
use icy2003\php\ihelpers\Http;
14
use icy2003\php\ihelpers\Json;
15
16
/**
17
 * 搜集的 API 接口
18
 */
19
class Api
20
{
21
    /**
22
     * 查询 ip 归属地
23
     *
24
     * @param string $ip IP 地址
25
     *
26
     * @return array|false
27
     */
28
    public static function ip($ip)
29
    {
30
        $res = Http::get('https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php', [
31
            'query' => $ip,
32
            'resource_id' => '6006',
33
            'oe' => 'utf8',
34
        ]);
35
        $data = Json::get($res, 'data.0.location', false);
36
        if (is_string($data)) {
37
            $array = [];
38
            list($array['city'], $array['type']) = Arrays::lists(explode(' ', $data), 2);
39
            return $array;
40
        }
41
        return false;
42
    }
43
44
    /**
45
     * 查询手机归属地
46
     *
47
     * @param string $mobile
48
     *
49
     * @return array|false
50
     */
51
    public static function mobile($mobile)
52
    {
53
        $res = Http::get('https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php', [
54
            'resource_name' => 'guishudi',
55
            'query' => $mobile,
56
            'oe' => 'utf8',
57
        ]);
58
        $data = Json::get($res, 'data.0', false);
59
        if (is_array($data)) {
60
            return [
61
                'city' => I::get($data, 'city'),
62
                'province' => I::get($data, 'prov'),
63
                'type' => I::get($data, 'type'),
64
            ];
65
        }
66
        return false;
67
    }
68
}
69