NginxWebServer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 2
dl 28
loc 28
ccs 11
cts 11
cp 1
rs 10
c 2
b 0
f 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A extractVersion() 4 4 1
A extractRootConfigurationFile() 4 4 1
A getActiveConfig() 4 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
 * This file is, guess what, part of WebHelper.
5
 *
6
 * (c) James <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace JamesRezo\WebHelper\WebServer;
13
14
use WebHelper\Parser\NginxParser;
15
16
/**
17
 * NginxWebServer is the webserver class for nginx httpd webserver.
18
 */
19 View Code Duplication
class NginxWebServer extends WebServer
0 ignored issues
show
Duplication introduced by
This class 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...
20
{
21
    /**
22
     * Constructor.
23
     *
24
     * @param string $version the semver-like version of the apache webserver
25
     */
26 12
    public function __construct($version = '')
27
    {
28 12
        parent::__construct('nginx', $version);
29 12
        $this->parser = new NginxParser();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \WebHelper\Parser\NginxParser() of type object<WebHelper\Parser\NginxParser> is incompatible with the declared type object<WebHelper\Parser\ParserInterface> of property $parser.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30 12
    }
31
32 4
    public function extractVersion($settings = '')
33
    {
34 4
        return $this->match('/^nginx version: nginx\/([0-9\.]+).*/', $settings);
35 1
    }
36
37 3
    public function extractRootConfigurationFile($settings = '')
38
    {
39 3
        return $this->match('/--conf-path=([^\s]+) /', $settings);
40
    }
41
42 1
    public function getActiveConfig($file = '')
43
    {
44 1
        return $this->parser->setConfigFile($file)->getActiveConfig();
45
    }
46
}
47