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.

StatusParser::parse()   B
last analyzed

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
/**
4
 * eduVPN - End-user friendly VPN.
5
 *
6
 * Copyright: 2016-2017, The Commons Conservancy eduVPN Programme
7
 * SPDX-License-Identifier: AGPL-3.0+
8
 */
9
10
namespace SURFnet\VPN\Server\OpenVpn;
11
12
/**
13
 * Parses the response from the OpenVPN `status 2` command.
14
 */
15
class StatusParser
16
{
17
    public static function parse(array $statusData)
18
    {
19
        $clientList = [];
20
21
        // find "HEADER,CLIENT_LIST"
22
        $i = 0;
23
        while (0 !== strpos($statusData[$i], 'HEADER,CLIENT_LIST')) {
24
            ++$i;
25
        }
26
        $clientKeys = array_slice(str_getcsv($statusData[$i]), 2);
27
        ++$i;
28
        // iterate over all CLIENT_LIST entries
29
        while (0 === strpos($statusData[$i], 'CLIENT_LIST')) {
30
            $clientValues = str_getcsv($statusData[$i]);
31
            array_shift($clientValues);
32
            $clientInfo = array_combine($clientKeys, $clientValues);
33
            $clientList[] = [
34
                'common_name' => $clientInfo['Common Name'],
35
                'virtual_address' => [
36
                    $clientInfo['Virtual Address'],
37
                    $clientInfo['Virtual IPv6 Address'],
38
                ],
39
            ];
40
            ++$i;
41
        }
42
43
        return $clientList;
44
    }
45
}
46