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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 44
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 3 1
A toString() 0 14 3
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