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 (#134)
by Yong
03:16
created

Encode::toString()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 4
nop 0
dl 0
loc 14
ccs 11
cts 11
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client;
4
5
/**
6
 * Class Encode
7
 *
8
 * @package AlibabaCloud\Client
9
 */
10
class Encode
11
{
12
    /**
13
     * @var array
14
     */
15
    private $data;
16
17
    /**
18
     * Format constructor.
19
     *
20
     * @param array $data
21
     */
22 17
    private function __construct(array $data)
23
    {
24 17
        $this->data = $data;
25 17
    }
26
27
    /**
28
     * @param array $data
29
     *
30
     * @return static
31
     */
32 17
    public static function create(array $data)
33
    {
34 17
        return new static($data);
35
    }
36
37
    /**
38
     * @return mixed|string
39
     */
40 17
    public function toString()
41
    {
42 17
        ksort($this->data);
43 17
        $string = '';
44 17
        foreach ($this->data as $key => $value) {
45 17
            $encode = urlencode($value);
46 17
            $string .= "$key=$encode&";
47 17
        }
48
49 17
        if (0 < count($this->data)) {
50 17
            $string = substr($string, 0, -1);
51 17
        }
52
53 17
        return $string;
54
    }
55
}
56