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 ( e52c92...f27185 )
by Yong
04:58
created

UserAgent::__toString()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 25
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 4.0119

Importance

Changes 0
Metric Value
cc 4
eloc 20
nc 6
nop 0
dl 0
loc 25
ccs 20
cts 22
cp 0.9091
crap 4.0119
rs 9.6
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client\Request;
4
5
use AlibabaCloud\Client\AlibabaCloud;
6
use GuzzleHttp\Client;
7
8
/**
9
 * Class UserAgent
10
 *
11
 * @package AlibabaCloud\Client\Request
12
 */
13
class UserAgent
14
{
15
16
    /**
17
     * @var array
18
     */
19
    private static $userAgent = [];
20
21
    /**
22
     * @return string
23
     */
24 69
    public function __toString()
25
    {
26 69
        $os           = \PHP_OS;
27 69
        $os_version   = php_uname('r');
28 69
        $os_mode      = php_uname('m');
29 69
        $userAgent    = "AlibabaCloud ($os $os_version; $os_mode)";
30 69
        $userAgent    .= ' PHP/' . \PHP_VERSION;
31 69
        $userAgent    .= ' Client/' . AlibabaCloud::VERSION;
32 69
        $userAgent    .= ' Zend/' . zend_version();
33 69
        $userAgent    .= ' Guzzle/' . Client::VERSION;
34 69
        $curl_version = isset(\curl_version()['version'])
35 69
            ? \curl_version()['version']
36 69
            : '';
37 69
        $userAgent    .= ' CURL/' . $curl_version;
38 69
        $userAgent    .= ' ';
39
40 69
        $newUserAgent = [];
41 69
        foreach (self::$userAgent as $key => $value) {
42 9
            if ($value === null) {
43
                $newUserAgent[] = $key;
44
                continue;
45
            }
46 9
            $newUserAgent[] = $key . '/' . $value;
47 69
        }
48 69
        return $userAgent . \implode(' ', $newUserAgent);
49
    }
50
51
    /**
52
     * set User Agent of Alibaba Cloud.
53
     *
54
     * @param string $name
55
     * @param string $value
56
     *
57
     * @return $this
58
     */
59 1
    public function append($name, $value)
60
    {
61 1
        self::$userAgent[$name] = $value;
62
63 1
        return $this;
64
    }
65
}
66