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 ( d7e253...55763c )
by François
03:03
created

GroupsModule::init()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 2
eloc 14
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
namespace SURFnet\VPN\Server\Api;
19
20
use Psr\Log\LoggerInterface;
21
use SURFnet\VPN\Server\InstanceConfig;
22
23
/**
24
 * Handle API calls for Groups.
25
 *
26
 * XXX more logging!
27
 */
28
class GroupsModule implements ServiceModuleInterface
29
{
30
    /** @var \SURFnet\VPN\Server\InstanceConfig */
31
    private $instanceConfig;
32
33
    /** @var \Psr\Log\LoggerInterface */
34
    private $logger;
35
36
    public function __construct(InstanceConfig $instanceConfig, LoggerInterface $logger)
37
    {
38
        $this->instanceConfig = $instanceConfig;
39
        $this->logger = $logger;
40
    }
41
42
    public function init(Service $service)
43
    {
44
        $service->get(
45
            '/groups',
46
            function (array $serverData, array $getData, array $postData, array $hookData) {
47
                Utils::requireUser($hookData, ['portal']);
48
                $userId = Utils::requireParameter($getData, 'user_id');
49
                InputValidation::userId($userId);
50
51
                $groupMembership = [];
52
                foreach ($this->instanceConfig->groupProviders() as $groupProviderId) {
53
                    $groupProviderConfig = $this->instanceConfig->groupProvider($groupProviderId);
54
                    $groupProviderClass = sprintf('SURFnet\VPN\Server\GroupProvider\%s', $groupProviderId);
55
                    $groupProvider = new $groupProviderClass($groupProviderConfig);
56
                    $groupMembership = array_merge($groupMembership, $groupProvider->getGroups($userId));
57
                }
58
59
                return new ApiResponse('groups', $groupMembership);
60
            }
61
        );
62
    }
63
}
64