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 (#73)
by Yong
11:11 queued 02:01
created

CredentialFilter   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 57
dl 0
loc 144
ccs 62
cts 62
cp 1
rs 10
c 0
b 0
f 0
wmc 19

5 Methods

Rating   Name   Duplication   Size   Complexity  
A roleName() 0 17 3
A privateKeyFile() 0 17 3
A bearerToken() 0 17 3
A publicKeyId() 0 17 3
B AccessKey() 0 35 7
1
<?php
2
3
namespace AlibabaCloud\Client\Filter;
4
5
use AlibabaCloud\Client\Exception\ClientException;
6
7
/**
8
 * Class CredentialFilter
9
 *
10
 * @package AlibabaCloud\Client\Filter
11
 */
12
class CredentialFilter
13
{
14
    /**
15
     * @param $bearerToken
16
     *
17
     * @return mixed
18
     * @throws ClientException
19
     */
20 27
    public static function bearerToken($bearerToken)
21
    {
22 27
        if (!is_string($bearerToken)) {
23 2
            throw new ClientException(
24 2
                'Bearer Token must be a string',
25
                \ALIBABA_CLOUD_INVALID_ARGUMENT
26 2
            );
27
        }
28
29 25
        if ($bearerToken === '') {
30 2
            throw new ClientException(
31 2
                'Bearer Token cannot be empty',
32
                \ALIBABA_CLOUD_INVALID_ARGUMENT
33 2
            );
34
        }
35
36 23
        return $bearerToken;
37
    }
38
39
    /**
40
     * @param $publicKeyId
41
     *
42
     * @return mixed
43
     * @throws ClientException
44
     */
45 27
    public static function publicKeyId($publicKeyId)
46
    {
47 27
        if (!is_string($publicKeyId)) {
48 2
            throw new ClientException(
49 2
                'Public Key ID must be a string',
50
                \ALIBABA_CLOUD_INVALID_ARGUMENT
51 2
            );
52
        }
53
54 25
        if ($publicKeyId === '') {
55 2
            throw new ClientException(
56 2
                'Public Key ID cannot be empty',
57
                \ALIBABA_CLOUD_INVALID_ARGUMENT
58 2
            );
59
        }
60
61 23
        return $publicKeyId;
62
    }
63
64
    /**
65
     * @param $privateKeyFile
66
     *
67
     * @return mixed
68
     * @throws ClientException
69
     */
70 23
    public static function privateKeyFile($privateKeyFile)
71
    {
72 23
        if (!is_string($privateKeyFile)) {
73 2
            throw new ClientException(
74 2
                'Private Key File must be a string',
75
                \ALIBABA_CLOUD_INVALID_ARGUMENT
76 2
            );
77
        }
78
79 21
        if ($privateKeyFile === '') {
80 2
            throw new ClientException(
81 2
                'Private Key File cannot be empty',
82
                \ALIBABA_CLOUD_INVALID_ARGUMENT
83 2
            );
84
        }
85
86 19
        return $privateKeyFile;
87
    }
88
89
    /**
90
     * @param $roleName
91
     *
92
     * @return string
93
     *
94
     * @throws ClientException
95
     */
96 30
    public static function roleName($roleName)
97
    {
98 30
        if (!is_string($roleName)) {
99 2
            throw new ClientException(
100 2
                'Role Name must be a string',
101
                \ALIBABA_CLOUD_INVALID_ARGUMENT
102 2
            );
103
        }
104
105 28
        if ($roleName === '') {
106 2
            throw new ClientException(
107 2
                'Role Name cannot be empty',
108
                \ALIBABA_CLOUD_INVALID_ARGUMENT
109 2
            );
110
        }
111
112 26
        return $roleName;
113
    }
114
115
    /**
116
     * @param $accessKeyId
117
     * @param $accessKeySecret
118
     *
119
     * @throws ClientException
120
     */
121 144
    public static function AccessKey($accessKeyId, $accessKeySecret)
122
    {
123 144
        if (is_numeric($accessKeyId)) {
124 5
            $accessKeyId = (string)$accessKeyId;
125 5
        }
126
127 144
        if (is_numeric($accessKeySecret)) {
128 5
            $accessKeySecret = (string)$accessKeySecret;
129 5
        }
130
131 144
        if (!is_string($accessKeyId)) {
132 6
            throw new ClientException(
133 6
                'AccessKey ID must be a string',
134
                \ALIBABA_CLOUD_INVALID_ARGUMENT
135 6
            );
136
        }
137
138 138
        if ($accessKeyId === '') {
139 6
            throw new ClientException(
140 6
                'AccessKey ID cannot be empty',
141
                \ALIBABA_CLOUD_INVALID_ARGUMENT
142 6
            );
143
        }
144
145 132
        if (!is_string($accessKeySecret)) {
146 6
            throw new ClientException(
147 6
                'AccessKey Secret must be a string',
148
                \ALIBABA_CLOUD_INVALID_ARGUMENT
149 6
            );
150
        }
151
152 126
        if ($accessKeySecret === '') {
153 6
            throw new ClientException(
154 6
                'AccessKey Secret cannot be empty',
155
                \ALIBABA_CLOUD_INVALID_ARGUMENT
156 6
            );
157
        }
158 120
    }
159
}
160