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

CommonNamesModule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
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 Psr\Log\LoggerInterface;
21
22
class CommonNamesModule implements ServiceModuleInterface
23
{
24
    /** @var CommonNames */
25
    private $commonNames;
26
27
    /** @var \Psr\Log\LoggerInterface */
28
    private $logger;
29
30
    public function __construct(CommonNames $commonNames, LoggerInterface $logger)
31
    {
32
        $this->commonNames = $commonNames;
33
        $this->logger = $logger;
34
    }
35
36
    public function init(Service $service)
37
    {
38
        $service->get(
39
            '/common_names/disabled',
40
            function (array $serverData, array $getData, array $postData, array $hookData) {
41
                Utils::requireUser($hookData, ['admin', 'portal']);
42
43
                return new ApiResponse('common_names', $this->commonNames->getDisabled());
44
            }
45
        );
46
47
        $service->post(
48
            '/common_names/disable',
49 View Code Duplication
            function (array $serverData, array $getData, array $postData, array $hookData) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
50
                Utils::requireUser($hookData, ['admin', 'portal']);
51
                $commonName = Utils::requireParameter($postData, 'common_name');
52
                InputValidation::commonName($commonName);
53
                $this->logger->info(sprintf('disabling common_name "%s"', $commonName));
54
55
                return new ApiResponse('ok', $this->commonNames->setDisabled($commonName));
56
            }
57
        );
58
59
        $service->post(
60
            '/common_names/enable',
61 View Code Duplication
            function (array $serverData, array $getData, array $postData, array $hookData) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
                Utils::requireUser($hookData, ['admin']);
63
                $commonName = Utils::requireParameter($postData, 'common_name');
64
                InputValidation::commonName($commonName);
65
                $this->logger->info(sprintf('enabling common_name "%s"', $commonName));
66
67
                return new ApiResponse('ok', $this->commonNames->setEnabled($commonName));
68
            }
69
        );
70
    }
71
}
72