Code Duplication    Length = 28-35 lines in 2 locations

src/WebServer/ApacheWebServer.php 1 location

@@ 19-53 (lines=35) @@
16
/**
17
 * ApacheWebServer is the webserver class for apache httpd webserver.
18
 */
19
class ApacheWebServer extends WebServer
20
{
21
    /**
22
     * Constructor.
23
     *
24
     * @param string $version the semver-like version of the apache webserver
25
     */
26
    public function __construct($version = '')
27
    {
28
        parent::__construct('apache', $version);
29
        $this->parser = new ApacheParser();
30
    }
31
32
    public function extractVersion($settings = '')
33
    {
34
        return $this->match('/^Server version: Apache\/([0-9\.]+) .*/', $settings);
35
    }
36
37
    public function extractRootConfigurationFile($settings = '')
38
    {
39
        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
    public function getActiveConfig($file = '')
50
    {
51
        return $this->parser->setConfigFile($file)->getActiveConfig();
52
    }
53
}
54

src/WebServer/NginxWebServer.php 1 location

@@ 19-46 (lines=28) @@
16
/**
17
 * NginxWebServer is the webserver class for nginx httpd webserver.
18
 */
19
class NginxWebServer extends WebServer
20
{
21
    /**
22
     * Constructor.
23
     *
24
     * @param string $version the semver-like version of the apache webserver
25
     */
26
    public function __construct($version = '')
27
    {
28
        parent::__construct('nginx', $version);
29
        $this->parser = new NginxParser();
30
    }
31
32
    public function extractVersion($settings = '')
33
    {
34
        return $this->match('/^nginx version: nginx\/([0-9\.]+).*/', $settings);
35
    }
36
37
    public function extractRootConfigurationFile($settings = '')
38
    {
39
        return $this->match('/--conf-path=([^\s]+) /', $settings);
40
    }
41
42
    public function getActiveConfig($file = '')
43
    {
44
        return $this->parser->setConfigFile($file)->getActiveConfig();
45
    }
46
}
47