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 ( bfa68a...9d2e01 )
by François
02:42
created

StatusParser::parse()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 28
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 8.8571
c 0
b 0
f 0
cc 3
eloc 18
nc 4
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\Server\OpenVpn;
20
21
/**
22
 * Parses the response from the OpenVPN `status 2` command.
23
 */
24
class StatusParser
25
{
26
    public static function parse(array $statusData)
27
    {
28
        $clientList = [];
29
30
        // find "HEADER,CLIENT_LIST"
31
        $i = 0;
32
        while (0 !== strpos($statusData[$i], 'HEADER,CLIENT_LIST')) {
33
            ++$i;
34
        }
35
        $clientKeys = array_slice(str_getcsv($statusData[$i]), 2);
36
        ++$i;
37
        // iterate over all CLIENT_LIST entries
38
        while (0 === strpos($statusData[$i], 'CLIENT_LIST')) {
39
            $clientValues = str_getcsv($statusData[$i]);
40
            array_shift($clientValues);
41
            $clientInfo = array_combine($clientKeys, $clientValues);
42
            $clientList[] = [
43
                'common_name' => $clientInfo['Common Name'],
44
                'virtual_address' => [
45
                    $clientInfo['Virtual Address'],
46
                    $clientInfo['Virtual IPv6 Address'],
47
                ],
48
            ];
49
            ++$i;
50
        }
51
52
        return $clientList;
53
    }
54
}
55