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 ( 2cf1d1...ef7b48 )
by François
02:38
created

ServerClient::userGroups()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 2
nc 1
nop 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
19
namespace SURFnet\VPN\Common\HttpClient;
20
21
class ServerClient extends BaseClient
22
{
23
    public function __construct(HttpClientInterface $httpClient, $baseUri)
24
    {
25
        parent::__construct($httpClient, $baseUri);
26
    }
27
28
    public function clientConnections()
29
    {
30
        return $this->get('client_connections');
31
    }
32
33
    public function log($dateTime, $ipAddress)
34
    {
35
        return $this->get(
36
            'log',
37
            [
38
                'date_time' => $dateTime,
39
                'ip_address' => $ipAddress,
40
            ]
41
        );
42
    }
43
44
    public function stats()
45
    {
46
        return $this->get('stats');
47
    }
48
49
    public function addClientCertificate($userId, $displayName)
50
    {
51
        return $this->post(
52
            'add_client_certificate',
53
            [
54
                'user_id' => $userId,
55
                'display_name' => $displayName,
56
            ]
57
        );
58
    }
59
60
    public function addServerCertificate($commonName)
61
    {
62
        return $this->post(
63
            'add_server_certificate',
64
            [
65
                'common_name' => $commonName,
66
            ]
67
        );
68
    }
69
70
    public function listClientCertificates($userId)
71
    {
72
        return $this->get('list_client_certificates', ['user_id' => $userId]);
73
    }
74
75
    public function enableUser($userId)
76
    {
77
        return $this->post('enable_user', ['user_id' => $userId]);
78
    }
79
80
    public function userList()
81
    {
82
        return $this->get('user_list');
83
    }
84
85
    public function disableUser($userId)
86
    {
87
        return $this->post('disable_user', ['user_id' => $userId]);
88
    }
89
90
    public function isDisabledUser($userId)
91
    {
92
        return $this->get('is_disabled_user', ['user_id' => $userId]);
93
    }
94
95
    public function disableClientCertificate($commonName)
96
    {
97
        return $this->post('disable_client_certificate', ['common_name' => $commonName]);
98
    }
99
100
    public function enableClientCertificate($commonName)
101
    {
102
        return $this->post('enable_client_certificate', ['common_name' => $commonName]);
103
    }
104
105
    public function killClient($commonName)
106
    {
107
        return $this->post('kill_client', ['common_name' => $commonName]);
108
    }
109
110
    public function profileList()
111
    {
112
        return $this->get('profile_list');
113
    }
114
115
    public function hasTotpSecret($userId)
116
    {
117
        return $this->get('has_totp_secret', ['user_id' => $userId]);
118
    }
119
120
    public function userGroups($userId)
0 ignored issues
show
Unused Code introduced by
The parameter $userId 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...
121
    {
122
        // XXX not yet implemented
123
        // return $this->get('user_groups', ['user_id' => $userId]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
124
125
        return [];
126
    }
127
128
    public function motd()
129
    {
130
        return $this->get('motd');
131
    }
132
133
    public function setMotd($motdMessage)
134
    {
135
        return $this->post('set_motd', ['motd_message' => $motdMessage]);
136
    }
137
138
    public function deleteMotd()
139
    {
140
        return $this->post('delete_motd', []);
141
    }
142
143
    public function setVootToken($userId, $vootToken)
144
    {
145
        return $this->post(
146
            'set_voot_token',
147
            [
148
                'user_id' => $userId,
149
                'voot_token' => $vootToken,
150
            ]
151
        );
152
    }
153
154
    public function deleteTotpSecret($userId)
155
    {
156
        return $this->post('delete_totp_secret', ['user_id' => $userId]);
157
    }
158
159
    public function setTotpSecret($userId, $totpSecret, $totpKey)
160
    {
161
        return $this->post(
162
            'set_totp_secret',
163
            [
164
                'user_id' => $userId,
165
                'totp_secret' => $totpSecret,
166
                'totp_key' => $totpKey,
167
            ]
168
        );
169
    }
170
171
    public function verifyTotpKey($userId, $totpKey)
172
    {
173
        return $this->post(
174
            'verify_totp_key',
175
            [
176
                'user_id' => $userId,
177
                'totp_key' => $totpKey,
178
            ]
179
        );
180
    }
181
182
    public function connect($profileId, $commonName, $ip4, $ip6, $connectedAt)
183
    {
184
        return $this->post(
185
            'connect',
186
            [
187
                'profile_id' => $profileId,
188
                'common_name' => $commonName,
189
                'ip4' => $ip4,
190
                'ip6' => $ip6,
191
                'connected_at' => $connectedAt,
192
            ]
193
        );
194
    }
195
196
    public function disconnect($profileId, $commonName, $ip4, $ip6, $connectedAt, $disconnectedAt, $bytesTransferred)
197
    {
198
        return $this->post(
199
            'disconnect',
200
            [
201
                'profile_id' => $profileId,
202
                'common_name' => $commonName,
203
                'ip4' => $ip4,
204
                'ip6' => $ip6,
205
                'connected_at' => $connectedAt,
206
                'disconnected_at' => $disconnectedAt,
207
                'bytes_transferred' => $bytesTransferred,
208
            ]
209
        );
210
    }
211
}
212