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.
Passed
Push — master ( b87887...138d7a )
by t
62:54 queued 27s
created

QQ::fetchInfo()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
1
<?php
2
/**
3
 * Class QQ
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2020, icy2003
8
 */
9
namespace icy2003\php\iapis;
10
11
use icy2003\php\C;
12
use icy2003\php\I;
13
use icy2003\php\ihelpers\Charset;
14
use icy2003\php\ihelpers\Http;
15
use icy2003\php\ihelpers\Json;
16
use icy2003\php\ihelpers\Strings;
17
18
/**
19
 * QQ 相关接口
20
 */
21
class QQ extends Api
22
{
23
    /**
24
     * QQ
25
     *
26
     * @var string
27
     */
28
    protected $_qq;
29
30
    /**
31
     * 初始化
32
     *
33
     * @param string $qq
34
     */
35
    public function __construct($qq)
36
    {
37
        C::assertTrue(preg_match('|^[1-9]\d{4,10}$|i', $qq) > 0, 'QQ 号格式错误');
38
        $this->_qq = $qq;
39
    }
40
41
    /**
42
     * 获取 QQ 的昵称和头像地址
43
     *
44
     * @param array $config 可设置头像规格,默认 3
45
     * - 1~5 分别表示 `40*40`, `40*40`, `100*100`, `140*140`, `640*640`
46
     *
47
     * @return static
48
     */
49
    public function fetchInfo($config = ['spec'=>3])
50
    {
51
        $result = Http::get('http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg', [
52
            'uins' => $this->_qq,
53
        ]);
54
        if (Strings::isContains($result, 'portraitCallBack')) {
55
            $json = Json::decode(Strings::partBetween($result, 'portraitCallBack(', ')'));
56
            $this->_result['nickname'] = Charset::toUtf(I::get($json, $this->_qq . '.6'), 'GBK');
0 ignored issues
show
Bug introduced by
It seems like icy2003\php\I::get($json, $this->_qq . '.6') can also be of type false; however, parameter $string of icy2003\php\ihelpers\Charset::toUtf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

56
            $this->_result['nickname'] = Charset::toUtf(/** @scrutinizer ignore-type */ I::get($json, $this->_qq . '.6'), 'GBK');
Loading history...
57
        }
58
        $this->_result['portrait'] = 'https://q2.qlogo.cn/headimg_dl?dst_uin='.$this->_qq.'&spec='. I::get($config, 'spec', 3);
59
60
        return $this;
61
    }
62
}