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.

HttpFilter::accept()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 1
dl 0
loc 17
ccs 10
cts 10
cp 1
crap 3
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace AlibabaCloud\Client\Filter;
4
5
use AlibabaCloud\Client\SDK;
6
use AlibabaCloud\Client\Exception\ClientException;
7
8
/**
9
 * Class HttpFilter
10
 *
11
 * @package AlibabaCloud\Client\Filter
12
 */
13
class HttpFilter
14
{
15
    /**
16
     * @param $host
17
     *
18
     * @return string
19
     *
20
     * @throws ClientException
21
     */
22 39
    public static function host($host)
23
    {
24 39
        if (!is_string($host)) {
25 3
            throw new ClientException(
26 3
                'Host must be a string',
27
                SDK::INVALID_ARGUMENT
28 3
            );
29
        }
30
31 36
        if ($host === '') {
32 3
            throw new ClientException(
33 3
                'Host cannot be empty',
34
                SDK::INVALID_ARGUMENT
35 3
            );
36
        }
37
38 33
        return $host;
39
    }
40
41
    /**
42
     * @param $scheme
43
     *
44
     * @return string
45
     *
46
     * @throws ClientException
47
     */
48 17
    public static function scheme($scheme)
49
    {
50 17
        if (!is_string($scheme)) {
51 1
            throw new ClientException(
52 1
                'Scheme must be a string',
53
                SDK::INVALID_ARGUMENT
54 1
            );
55
        }
56
57 16
        if ($scheme === '') {
58 1
            throw new ClientException(
59 1
                'Scheme cannot be empty',
60
                SDK::INVALID_ARGUMENT
61 1
            );
62
        }
63
64 15
        return $scheme;
65
    }
66
67
    /**
68
     * @param $body
69
     *
70
     * @return mixed
71
     * @throws ClientException
72
     */
73 5
    public static function body($body)
74
    {
75 5
        if (!is_string($body) && !is_numeric($body)) {
76 1
            throw new ClientException(
77 1
                'Body must be a string or int',
78
                SDK::INVALID_ARGUMENT
79 1
            );
80
        }
81
82 4
        if ($body === '') {
83 1
            throw new ClientException(
84 1
                'Body cannot be empty',
85
                SDK::INVALID_ARGUMENT
86 1
            );
87
        }
88
89 3
        return $body;
90
    }
91
92
    /**
93
     * @param $method
94
     *
95
     * @return mixed
96
     * @throws ClientException
97
     */
98 54
    public static function method($method)
99
    {
100 54
        if (!is_string($method)) {
101 1
            throw new ClientException(
102 1
                'Method must be a string',
103
                SDK::INVALID_ARGUMENT
104 1
            );
105
        }
106
107 53
        if ($method === '') {
108 1
            throw new ClientException(
109 1
                'Method cannot be empty',
110
                SDK::INVALID_ARGUMENT
111 1
            );
112
        }
113
114 52
        return \strtoupper($method);
115
    }
116
117
    /**
118
     * @param $contentType
119
     *
120
     * @return mixed
121
     * @throws ClientException
122
     */
123 4
    public static function contentType($contentType)
124
    {
125 4
        if (!is_string($contentType)) {
126 1
            throw new ClientException(
127 1
                'Content-Type must be a string',
128
                SDK::INVALID_ARGUMENT
129 1
            );
130
        }
131
132 3
        if ($contentType === '') {
133 1
            throw new ClientException(
134 1
                'Content-Type cannot be empty',
135
                SDK::INVALID_ARGUMENT
136 1
            );
137
        }
138
139 2
        return $contentType;
140
    }
141
142
    /**
143
     * @param $accept
144
     *
145
     * @return mixed
146
     * @throws ClientException
147
     */
148 8
    public static function accept($accept)
149
    {
150 8
        if (!is_string($accept)) {
151 2
            throw new ClientException(
152 2
                'Accept must be a string',
153
                SDK::INVALID_ARGUMENT
154 2
            );
155
        }
156
157 6
        if ($accept === '') {
158 2
            throw new ClientException(
159 2
                'Accept cannot be empty',
160
                SDK::INVALID_ARGUMENT
161 2
            );
162
        }
163
164 4
        return $accept;
165
    }
166
}
167