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 ( e69c3b...b35ce9 )
by François
08:06
created

StaticProvider::getGroups()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
rs 9.2
cc 4
eloc 11
nc 3
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\GroupProvider;
19
20
use SURFnet\VPN\Server\GroupProviderInterface;
21
use SURFnet\VPN\Server\InstanceConfig;
22
23
class StaticProvider implements GroupProviderInterface
24
{
25
    /** @var string */
26
    private $dataDir;
27
28
    /** @var \SURFnet\VPN\Server\InstanceConfig */
29
    private $instanceConfig;
30
31
    public function __construct($dataDir, InstanceConfig $instanceConfig)
32
    {
33
        $this->dataDir = $dataDir;
34
        $this->instanceConfig = $instanceConfig;
35
    }
36
37
    public function getGroups($userId)
38
    {
39
        $memberOf = [];
40
41
        $groupIdList = array_keys($this->instanceConfig->v('groupProviders', 'StaticProvider'));
42
        foreach ($groupIdList as $groupId) {
43
            $memberList = $this->instanceConfig->v('groupProviders', 'StaticProvider', $groupId, 'members');
44
            if (!is_array($memberList) || !in_array($userId, $memberList)) {
45
                continue;
46
            }
47
48
            $memberOf[] = [
49
                'id' => $groupId,
50
                'displayName' => $this->instanceConfig->v('groupProviders', 'StaticProvider', $groupId, 'displayName'),
51
            ];
52
        }
53
54
        return $memberOf;
55
    }
56
}
57