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 ( bf4402...8854eb )
by François
07:55
created

Utils::getProcessCount()   B

Complexity

Conditions 10
Paths 10

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 7.2765
c 0
b 0
f 0
cc 10
eloc 16
nc 10
nop 1

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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;
19
20
class Utils
21
{
22
    /**
23
     * Depending on the size of the prefix assigned to this pool, this method
24
     * will return the number of OpenVPN processes backing that range, each
25
     * pool range is split in #processCount number of OpenVPN processes.
26
     */
27
    public static function getProcessCount($prefix)
28
    {
29
        switch ($prefix) {
30
            case 32:    // 1 IP
31
            case 31:    // 2 IPs
32
                throw new RuntimeException('not enough available IPs in range');
33
            case 30:    // 4 IPs (1 usable for client, no splitting)
34
            case 29:    // 8 IPs (5 usable for clients, no splitting)
35
                return 1;
36
            case 28:    // 16 IPs (12 usable for clients)
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
            case 27:    // 32 IPs
38
            case 26:    // 64 IPs
39
            case 25:    // 128 IPs
40
                return 2;
41
            case 24:
42
                return 4;
43
        }
44
45
        return 8;
46
    }
47
}
48