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.

StaticProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getGroups() 0 19 4
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\Acl\Provider;
11
12
use SURFnet\VPN\Common\Config;
13
use SURFnet\VPN\Server\Acl\ProviderInterface;
14
15
class StaticProvider implements ProviderInterface
16
{
17
    /** @var \SURFnet\VPN\Common\Config */
18
    private $config;
19
20
    public function __construct(Config $config)
21
    {
22
        $this->config = $config;
23
    }
24
25
    /**
26
     * Get the groups a user is a member of.
27
     *
28
     * @param string userId the userID of the user to request the groups of
29
     *
30
     * @return array the groups as an array containing the keys "id" and
31
     *               "displayName", empty array if no groups are available for this user
32
     */
33
    public function getGroups($userId)
34
    {
35
        $memberOf = [];
36
37
        $groupIdList = array_keys($this->config->toArray());
38
        foreach ($groupIdList as $groupId) {
39
            $memberList = $this->config->getSection($groupId)->getSection('members')->toArray();
40
            if (!is_array($memberList) || !in_array($userId, $memberList)) {
41
                continue;
42
            }
43
44
            $memberOf[] = [
45
                'id' => $groupId,
46
                'displayName' => $this->config->getSection($groupId)->getItem('displayName'),
47
            ];
48
        }
49
50
        return $memberOf;
51
    }
52
}
53