Completed
Push — master ( 532b1f...89ab0b )
by Mr
04:53 queued 11s
created

ConfigWrapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 45.45 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 15
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClient() 8 8 1
A getServer() 7 7 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\Interfaces\ConfigInterface;
7
8
class ConfigWrapper
9
{
10
    /**
11
     * Get client configuration of OpenVPN
12
     *
13
     * @param array $params
14
     *
15
     * @return \OpenVPN\Interfaces\ConfigInterface
16
     */
17 View Code Duplication
    public function getClient(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...
18
    {
19
        $configs = config('openvpn-client');
20
        $configs = array_merge($configs, $params);
21
        $object  = new Config($configs);
22
23
        return $object->client();
24
    }
25
26
    /**
27
     * Get server configuration of OpenVPN
28
     *
29
     * @param array $params
30
     *
31
     * @return \OpenVPN\Interfaces\ConfigInterface
32
     */
33 View Code Duplication
    public function getServer(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...
34
    {
35
        $configs = config('openvpn-server');
36
        $configs = array_merge($configs, $params);
37
38
        return new Config($configs);
39
    }
40
}
41