ApacheWebServer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

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\ApacheParser;
15
16
/**
17
 * ApacheWebServer is the webserver class for apache httpd webserver.
18
 */
19 View Code Duplication
class ApacheWebServer 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 15
    public function __construct($version = '')
27
    {
28 15
        parent::__construct('apache', $version);
29 15
        $this->parser = new ApacheParser();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \WebHelper\Parser\ApacheParser() of type object<WebHelper\Parser\ApacheParser> 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 15
    }
31
32 3
    public function extractVersion($settings = '')
33
    {
34 3
        return $this->match('/^Server version: Apache\/([0-9\.]+) .*/', $settings);
35
    }
36
37 3
    public function extractRootConfigurationFile($settings = '')
38
    {
39 3
        return $this->match('/ -D SERVER_CONFIG_FILE="([^"]+)"/', $settings);
40
    }
41
42
    /**
43
     * Loads and cleans a config file.
44
     *
45
     * @param string $file a Configuration file
46
     *
47
     * @return array an array of the cleaned directives of a the config per entry
48
     */
49 1
    public function getActiveConfig($file = '')
50
    {
51 1
        return $this->parser->setConfigFile($file)->getActiveConfig();
52
    }
53
}
54