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.

InfoModule::init()   B
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 15
nc 1
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\Api;
11
12
use SURFnet\VPN\Common\Config;
13
use SURFnet\VPN\Common\Http\ApiResponse;
14
use SURFnet\VPN\Common\Http\AuthUtils;
15
use SURFnet\VPN\Common\Http\Request;
16
use SURFnet\VPN\Common\Http\Service;
17
use SURFnet\VPN\Common\Http\ServiceModuleInterface;
18
use SURFnet\VPN\Common\ProfileConfig;
19
20
class InfoModule implements ServiceModuleInterface
21
{
22
    /** @var \SURFnet\VPN\Common\Config */
23
    private $config;
24
25
    public function __construct(Config $config)
26
    {
27
        $this->config = $config;
28
    }
29
30
    public function init(Service $service)
31
    {
32
        /* INFO */
33
        $service->get(
34
            '/instance_number',
35
            function (Request $request, array $hookData) {
36
                AuthUtils::requireUser($hookData, ['vpn-server-node']);
37
38
                return new ApiResponse('instance_number', $this->config->getItem('instanceNumber'));
39
            }
40
        );
41
42
        $service->get(
43
            '/profile_list',
44
            function (Request $request, array $hookData) {
45
                AuthUtils::requireUser($hookData, ['vpn-admin-portal', 'vpn-user-portal', 'vpn-server-node']);
46
47
                $profileList = [];
48
                foreach ($this->config->getSection('vpnProfiles')->toArray() as $profileId => $profileData) {
49
                    $profileConfig = new ProfileConfig($profileData);
50
                    $profileList[$profileId] = $profileConfig->toArray();
51
                }
52
53
                return new ApiResponse('profile_list', $profileList);
54
            }
55
        );
56
    }
57
}
58