Wrapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 25.86 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 15
loc 58
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A client() 8 8 1
A server() 7 7 1
A generator() 0 4 1
A importer() 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
namespace OpenVPN\Laravel;
4
5
use OpenVPN\Config;
6
use OpenVPN\Generator;
7
use OpenVPN\Import;
8
use OpenVPN\Interfaces\ConfigInterface;
9
use OpenVPN\Interfaces\GeneratorInterface;
10
use OpenVPN\Interfaces\ImportInterface;
11
12
class Wrapper
13
{
14
    /**
15
     * Get client configuration of OpenVPN
16
     *
17
     * @param array $params
18
     *
19
     * @return \OpenVPN\Interfaces\ConfigInterface
20
     */
21 View Code Duplication
    public function client(array $params = []): ConfigInterface
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...
22
    {
23
        $configs = config('openvpn-client');
24
        $configs = array_merge($configs, $params);
25
        $object  = new Config($configs);
26
27
        return $object->client();
28
    }
29
30
    /**
31
     * Get server configuration of OpenVPN
32
     *
33
     * @param array $params
34
     *
35
     * @return \OpenVPN\Interfaces\ConfigInterface
36
     */
37 View Code Duplication
    public function server(array $params = []): ConfigInterface
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...
38
    {
39
        $configs = config('openvpn-server');
40
        $configs = array_merge($configs, $params);
41
42
        return new Config($configs);
43
    }
44
45
    /**
46
     * Get instance of config generator
47
     *
48
     * @param \OpenVPN\Interfaces\ConfigInterface $config
49
     *
50
     * @return \OpenVPN\Interfaces\GeneratorInterface
51
     */
52
    public function generator(ConfigInterface $config): GeneratorInterface
53
    {
54
        return new Generator($config);
55
    }
56
57
    /**
58
     * Get instance of config importer
59
     *
60
     * @param string|null $filename
61
     * @param bool        $isContent
62
     *
63
     * @return \OpenVPN\Interfaces\ImportInterface
64
     */
65
    public function importer(string $filename = null, bool $isContent = false): ImportInterface
66
    {
67
        return new Import($filename, $isContent);
68
    }
69
}
70