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
04:40
created

Encode::ksort()   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 0
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;
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