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 ( ca8e01...1c7c8f )
by Yong
03:46
created

Encode   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 53
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 3 1
A toString() 0 13 3
A ksort() 0 5 1
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
     * @param array $data
19
     *
20
     * @return static
21
     */
22 43
    public static function create(array $data)
23
    {
24 43
        return new static($data);
25
    }
26
27
    /**
28
     * Encode constructor.
29
     *
30
     * @param array $data
31
     */
32 43
    private function __construct(array $data)
33
    {
34 43
        $this->data = $data;
35 43
    }
36
37
    /**
38
     * @return bool|string
39
     */
40 43
    public function toString()
41
    {
42 43
        $string = '';
43 43
        foreach ($this->data as $key => $value) {
44 43
            $encode = rawurlencode($value);
45 43
            $string .= "$key=$encode&";
46 43
        }
47
48 43
        if (0 < count($this->data)) {
49 43
            $string = substr($string, 0, -1);
50 43
        }
51
52 43
        return $string;
53
    }
54
55
    /**
56
     * @return $this
57
     */
58 18
    public function ksort()
59
    {
60 18
        ksort($this->data);
61
62 18
        return $this;
63
    }
64
}
65