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
Pull Request — master (#48)
by Yong
04:56
created

UserAgent::append()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
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 68
    public function __toString()
25
    {
26 68
        $os           = \PHP_OS;
27 68
        $os_version   = php_uname('r');
28 68
        $os_mode      = php_uname('m');
29 68
        $userAgent    = "AlibabaCloud ($os $os_version; $os_mode)";
30 68
        $userAgent    .= ' PHP/' . \PHP_VERSION;
31 68
        $userAgent    .= ' Client/' . AlibabaCloud::VERSION;
32 68
        $userAgent    .= ' Zend/' . zend_version();
33 68
        $userAgent    .= ' Guzzle/' . Client::VERSION;
34 68
        $curl_version = isset(\curl_version()['version'])
35 68
            ? \curl_version()['version']
36 68
            : '';
37 68
        $userAgent    .= ' CURL/' . $curl_version;
38 68
        $userAgent    .= ' ';
39
40 68
        $newUserAgent = [];
41 68
        foreach (self::$userAgent as $key => $value) {
42 8
            if ($value === null) {
43
                $newUserAgent[] = $key;
44
                continue;
45
            }
46 8
            $newUserAgent[] = $key . '/' . $value;
47 68
        }
48 68
        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