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 ( 6b8536...d0f704 )
by François
02:42
created

LogModule::get()   C

Complexity

Conditions 8
Paths 7

Size

Total Lines 30
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 5.3846
c 0
b 0
f 0
cc 8
eloc 19
nc 7
nop 2
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 SURFnet\VPN\Common\Http\ServiceModuleInterface;
21
use SURFnet\VPN\Common\Http\Service;
22
use SURFnet\VPN\Common\Http\ApiResponse;
23
use SURFnet\VPN\Common\Http\Request;
24
use SURFnet\VPN\Common\FileIO;
25
26
class LogModule implements ServiceModuleInterface
27
{
28
    /** @var ConnectionLog */
29
    private $connectionLog;
30
31
    public function __construct(ConnectionLog $connectionLog)
32
    {
33
        $this->connectionLog = $connectionLog;
34
    }
35
36
    public function init(Service $service)
37
    {
38
        $service->get(
39
            '/log',
40
            function (Request $request, array $hookData) {
41
                Utils::requireUser($hookData, ['vpn-admin-portal']);
42
43
                $dateTime = $request->getQueryParameter('date_time');
44
                InputValidation::dateTime($dateTime);
45
46
                // do not convert if we have a number, it is probably already unix time
47
                $dateTimeUnix = is_numeric($dateTime) ? intval($dateTime) : strtotime($dateTime);
48
49
                $ipAddress = $request->getQueryParameter('ip_address');
50
                InputValidation::ipAddress($ipAddress);
51
52
                $logData = $this->connectionLog->get($dateTimeUnix, $ipAddress);
53
                if (false !== $logData) {
54
                    foreach ($logData as $k => $value) {
55
                        $logData[$k]['user_id'] = substr($value['common_name'], 0, strpos($value['common_name'], '_'));
56
                        $logData[$k]['config_name'] = substr($value['common_name'], strpos($value['common_name'], '_') + 1);
57
                    }
58
                }
59
60
                return new ApiResponse('log', $logData);
61
            }
62
        );
63
64
//        $service->get(
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
65
//            '/stats',
66
//            function (Request $request, array $hookData) {
67
//                Utils::requireUser($hookData, ['vpn-admin-portal']);
68
//                $statsFile = sprintf('%s/stats.json', $this->dataDir);
69
70
//                return new ApiResponse('stats', FileIO::readJsonFile($statsFile));
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% 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...
71
//            }
72
//        );
73
    }
74
}
75