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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 92%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 51
ccs 23
cts 25
cp 0.92
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A append() 0 5 1
A __toString() 0 25 4
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