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.

TestCa   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 33.96 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 18
loc 53
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A serverCert() 9 9 1
A clientCert() 9 9 1
A caCert() 0 4 1
A init() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Tests;
11
12
use SURFnet\VPN\Common\Config;
13
use SURFnet\VPN\Server\CA\CaInterface;
14
15
class TestCa implements CaInterface
16
{
17
    /**
18
     * Generate a certificate for the VPN server.
19
     *
20
     * @param string $commonName
21
     *
22
     * @return array the certificate, key in array with keys
23
     *               'cert', 'key', 'valid_from' and 'valid_to'
24
     */
25 View Code Duplication
    public function serverCert($commonName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
26
    {
27
        return [
28
            'certificate' => sprintf('ServerCert for %s', $commonName),
29
            'private_key' => sprintf('ServerCert for %s', $commonName),
30
            'valid_from' => 1234567890,
31
            'valid_to' => 2345678901,
32
        ];
33
    }
34
35
    /**
36
     * Generate a certificate for a VPN client.
37
     *
38
     * @param string $commonName
39
     *
40
     * @return array the certificate and key in array with keys 'cert', 'key',
41
     *               'valid_from' and 'valid_to'
42
     */
43 View Code Duplication
    public function clientCert($commonName)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in 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...
44
    {
45
        return [
46
            'certificate' => sprintf('ClientCert for %s', $commonName),
47
            'private_key' => sprintf('ClientKey for %s', $commonName),
48
            'valid_from' => 1234567890,
49
            'valid_to' => 2345678901,
50
        ];
51
    }
52
53
    /**
54
     * Get the CA root certificate.
55
     *
56
     * @return string the CA certificate in PEM format
57
     */
58
    public function caCert()
59
    {
60
        return 'Ca';
61
    }
62
63
    public function init(Config $config)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65
        // NOP
66
    }
67
}
68