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

ApacheWebServer::parseActiveConfig()   C

Complexity

Conditions 7
Paths 33

Size

Total Lines 24
Code Lines 14

Duplication

Lines 3
Ratio 12.5 %

Code Coverage

Tests 5
CRAP Score 27.6718

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 3
loc 24
ccs 5
cts 20
cp 0.25
rs 6.7272
cc 7
eloc 14
nc 33
nop 1
crap 27.6718

1 Method

Rating   Name   Duplication   Size   Complexity  
A ApacheWebServer::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