Passed
Branch new-architecture (05bfee)
by James
04:16
created

ApacheWebServer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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
/**
15
 * ApacheWebServer is the webserver class for apache httpd webserver.
16
 */
17 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...
18
{
19
    /**
20
     * Constructor.
21
     *
22
     * @param string $version the semver-like version of the apache webserver
23
     */
24 11
    public function __construct($version = '')
25
    {
26 11
        parent::__construct('apache', $version);
27 11
    }
28
29 2
    public function extractVersion($settings = '')
30
    {
31 2
        $matches = [];
32 2
        $regexp = '/^Server version: Apache\/([0-9\.]+) .*/';
33
34 2
        if (preg_match($regexp, $settings, $matches)) {
35 1
            return $matches[1];
36
        }
37
38 1
        return '';
39
    }
40
41 2
    public function extractRootConfigurationFile($settings = '')
42
    {
43 2
        $matches = [];
44 2
        $regexp = '/ -D SERVER_CONFIG_FILE="([^"]+)"/';
45 2
        if (preg_match($regexp, $settings, $matches)) {
46 1
            return $matches[1];
47
        }
48
49 1
        return '';
50
    }
51
}
52