Completed
Push — master ( 69fb56...37d2a4 )
by James
05:09
created

ApacheWebServer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A extractVersion() 0 4 1
A extractRootConfigurationFile() 0 4 1
A getActiveConfig() 0 4 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
use WebHelper\Parser\ApacheParser;
15
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 15
    public function __construct($version = '')
27
    {
28 15
        parent::__construct('apache', $version);
29 15
        $this->parser = new ApacheParser();
0 ignored issues
show
Bug introduced by
The property parser does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
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