NginxWebServer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
dl 5
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 2
b 0
f 1
cc 1
eloc 3
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
use WebHelper\Parser\NginxParser;
15
16
/**
17
 * NginxWebServer is the webserver class for nginx httpd webserver.
18
 */
19 View Code Duplication
class NginxWebServer 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 12
    public function __construct($version = '')
27
    {
28 12
        parent::__construct('nginx', $version);
29 12
        $this->parser = new NginxParser();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \WebHelper\Parser\NginxParser() of type object<WebHelper\Parser\NginxParser> 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 12
    }
31
32 4
    public function extractVersion($settings = '')
33
    {
34 4
        return $this->match('/^nginx version: nginx\/([0-9\.]+).*/', $settings);
35 1
    }
36
37 3
    public function extractRootConfigurationFile($settings = '')
38
    {
39 3
        return $this->match('/--conf-path=([^\s]+) /', $settings);
40
    }
41
42 1
    public function getActiveConfig($file = '')
43
    {
44 1
        return $this->parser->setConfigFile($file)->getActiveConfig();
45
    }
46
}
47