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
09:51
created

HttpFilter::host()   A

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\Exception\ClientException;
6
7
/**
8
 * Class HttpFilter
9
 *
10
 * @package AlibabaCloud\Client\Filter
11
 */
12
class HttpFilter
13
{
14
    /**
15
     * @param $host
16
     *
17
     * @return string
18
     *
19
     * @throws ClientException
20
     */
21 47
    public static function host($host)
22
    {
23 47
        if (!is_string($host)) {
24 3
            throw new ClientException(
25 3
                'Host must be a string',
26
                \ALIBABA_CLOUD_INVALID_ARGUMENT
27 3
            );
28
        }
29
30 44
        if ($host === '') {
31 3
            throw new ClientException(
32 3
                'Host cannot be empty',
33
                \ALIBABA_CLOUD_INVALID_ARGUMENT
34 3
            );
35
        }
36
37 41
        return $host;
38
    }
39
40
    /**
41
     * @param $scheme
42
     *
43
     * @return string
44
     *
45
     * @throws ClientException
46
     */
47 32
    public static function scheme($scheme)
48
    {
49 32
        if (!is_string($scheme)) {
50 1
            throw new ClientException(
51 1
                'Scheme must be a string',
52
                \ALIBABA_CLOUD_INVALID_ARGUMENT
53 1
            );
54
        }
55
56 31
        if ($scheme === '') {
57 1
            throw new ClientException(
58 1
                'Scheme cannot be empty',
59
                \ALIBABA_CLOUD_INVALID_ARGUMENT
60 1
            );
61
        }
62
63 30
        return $scheme;
64
    }
65
66
    /**
67
     * @param $body
68
     *
69
     * @return mixed
70
     * @throws ClientException
71
     */
72 7
    public static function body($body)
73
    {
74 7
        if (!is_string($body) && !is_numeric($body)) {
75 1
            throw new ClientException(
76 1
                'Body must be a string or int',
77
                \ALIBABA_CLOUD_INVALID_ARGUMENT
78 1
            );
79
        }
80
81 6
        if ($body === '') {
82 1
            throw new ClientException(
83 1
                'Body cannot be empty',
84
                \ALIBABA_CLOUD_INVALID_ARGUMENT
85 1
            );
86
        }
87
88 5
        return $body;
89
    }
90
91
    /**
92
     * @param $method
93
     *
94
     * @return mixed
95
     * @throws ClientException
96
     */
97 73
    public static function method($method)
98
    {
99 73
        if (!is_string($method)) {
100 1
            throw new ClientException(
101 1
                'Method must be a string',
102
                \ALIBABA_CLOUD_INVALID_ARGUMENT
103 1
            );
104
        }
105
106 72
        if ($method === '') {
107 1
            throw new ClientException(
108 1
                'Method cannot be empty',
109
                \ALIBABA_CLOUD_INVALID_ARGUMENT
110 1
            );
111
        }
112
113 71
        return \strtoupper($method);
114
    }
115
}
116