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.
Completed
Push — master ( 0c5788...600384 )
by François
02:29
created

ServerClient   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 167
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 10
Bugs 1 Features 5
Metric Value
wmc 24
c 10
b 1
f 5
lcom 2
cbo 1
dl 0
loc 167
rs 10

24 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A disableCommonName() 0 4 1
A enableCommonName() 0 4 1
A clientConnections() 0 4 1
A stats() 0 4 1
A disabledUsers() 0 4 1
A isDisabledUser() 0 4 1
A enableUser() 0 4 1
A disableUser() 0 4 1
A hasOtpSecret() 0 4 1
A disabledCommonNames() 0 4 1
A isDisabledCommonName() 0 4 1
A killClient() 0 4 1
A hasVootToken() 0 4 1
A setVootToken() 0 10 1
A deleteOtpSecret() 0 4 1
A setOtpSecret() 0 11 1
A verifyOtpKey() 0 10 1
A log() 0 10 1
A instanceConfig() 0 4 1
A userGroups() 0 4 1
A serverProfile() 0 4 1
A connect() 0 13 1
A disconnect() 0 15 1
1
<?php
2
/**
3
 *  Copyright (C) 2016 SURFnet.
4
 *
5
 *  This program is free software: you can redistribute it and/or modify
6
 *  it under the terms of the GNU Affero General Public License as
7
 *  published by the Free Software Foundation, either version 3 of the
8
 *  License, or (at your option) any later version.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU Affero General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU Affero General Public License
16
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
namespace SURFnet\VPN\Common\HttpClient;
19
20
class ServerClient extends BaseClient
21
{
22
    public function __construct(HttpClientInterface $httpClient, $baseUri)
23
    {
24
        parent::__construct($httpClient, $baseUri);
25
    }
26
27
    public function clientConnections()
28
    {
29
        return $this->get('client_connections');
30
    }
31
32
    public function log($dateTime, $ipAddress)
33
    {
34
        return $this->get(
35
            'log',
36
            [
37
                'date_time' => $dateTime,
38
                'ip_address' => $ipAddress,
39
            ]
40
        );
41
    }
42
43
    public function stats()
44
    {
45
        return $this->get('stats');
46
    }
47
48
    public function disabledUsers()
49
    {
50
        return $this->get('disabled_users');
51
    }
52
53
    public function isDisabledUser($userId)
54
    {
55
        return $this->get('is_disabled_user', ['user_id' => $userId]);
56
    }
57
58
    public function enableUser($userId)
59
    {
60
        return $this->post('enable_user', ['user_id' => $userId]);
61
    }
62
63
    public function disableUser($userId)
64
    {
65
        return $this->post('disable_user', ['user_id' => $userId]);
66
    }
67
68
    public function hasOtpSecret($userId)
69
    {
70
        return $this->get('has_otp_secret', ['user_id' => $userId]);
71
    }
72
73
    public function disabledCommonNames()
74
    {
75
        return $this->get('disabled_common_names');
76
    }
77
78
    public function isDisabledCommonName($commonName)
79
    {
80
        return $this->get('is_disabled_common_name', ['common_name' => $commonName]);
81
    }
82
83
    public function disableCommonName($commonName)
84
    {
85
        return $this->post('disable_common_name', ['common_name' => $commonName]);
86
    }
87
88
    public function enableCommonName($commonName)
89
    {
90
        return $this->post('enable_common_name', ['common_name' => $commonName]);
91
    }
92
93
    public function killClient($commonName)
94
    {
95
        return $this->post('kill_client', ['common_name' => $commonName]);
96
    }
97
98
    public function serverProfile($profileId)
99
    {
100
        return $this->get('server_profile', ['profile_id' => $profileId]);
101
    }
102
103
    public function instanceConfig()
104
    {
105
        return $this->get('instance_config');
106
    }
107
108
    public function userGroups($userId)
109
    {
110
        return $this->get('user_groups', ['user_id' => $userId]);
111
    }
112
113
    public function hasVootToken($userId)
114
    {
115
        return $this->get('has_voot_token', ['user_id' => $userId]);
116
    }
117
118
    public function setVootToken($userId, $vootToken)
119
    {
120
        return $this->post(
121
            'set_voot_token',
122
            [
123
                'user_id' => $userId,
124
                'voot_token' => $vootToken,
125
            ]
126
        );
127
    }
128
129
    public function deleteOtpSecret($userId)
130
    {
131
        return $this->post('delete_otp_secret', ['user_id' => $userId]);
132
    }
133
134
    public function setOtpSecret($userId, $otpSecret, $otpKey)
135
    {
136
        return $this->post(
137
            'set_otp_secret',
138
            [
139
                'user_id' => $userId,
140
                'otp_secret' => $otpSecret,
141
                'otp_key' => $otpKey,
142
            ]
143
        );
144
    }
145
146
    public function verifyOtpKey($userId, $otpKey)
147
    {
148
        return $this->post(
149
            'verify_otp_key',
150
            [
151
                'user_id' => $userId,
152
                'otp_key' => $otpKey,
153
            ]
154
        );
155
    }
156
157
    public function connect($profileId, $commonName, $ip4, $ip6, $connectedAt)
158
    {
159
        return $this->post(
160
            'connect',
161
            [
162
                'profile_id' => $profileId,
163
                'common_name' => $commonName,
164
                'ip4' => $ip4,
165
                'ip6' => $ip6,
166
                'connected_at' => $connectedAt,
167
            ]
168
        );
169
    }
170
171
    public function disconnect($profileId, $commonName, $ip, $ip6, $connectedAt, $disconnectedAt, $bytesTransferred)
0 ignored issues
show
Unused Code introduced by
The parameter $ip is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $ip. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
172
    {
173
        return $this->post(
174
            'disconnect',
175
            [
176
                'profile_id' => $profileId,
177
                'common_name' => $commonName,
178
                'ip4' => $ip4,
0 ignored issues
show
Bug introduced by
The variable $ip4 does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
179
                'ip6' => $ip6,
180
                'connected_at' => $connectedAt,
181
                'disconnected_at' => $disconnectedAt,
182
                'bytes_transferred' => $bytesTransferred,
183
            ]
184
        );
185
    }
186
}
187