Passed
Branch new-architecture (764111)
by James
02:34
created

WebServerFactory::create()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 17
ccs 12
cts 12
cp 1
rs 9.4285
cc 3
eloc 12
nc 3
nop 2
crap 3
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
 * WebServer Factory Class.
16
 *
17
 * @author James <[email protected]>
18
 */
19
class WebServerFactory
20
{
21
    /**
22
     * Create a WebServerInterface Object.
23
     *
24
     * @param string $name    a web server software name
25
     * @param string $version a web server software version
26
     *
27
     * @return WebServerInterface a WebServer Object
28
     */
29 3
    public function create($name, $version)
30
    {
31 3
        $webserver = null;
0 ignored issues
show
Unused Code introduced by
$webserver is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
32
33
        switch ($name) {
34 3
            case 'apache':
35 1
                $webserver = new ApacheWebServer($version);
36 1
                break;
37 2
            case 'nginx':
38 1
                $webserver = new NginxWebServer($version);
39 1
                break;
40 1
            default:
41 1
                $webserver = new NullWebServer($version);
42 1
        }
43
44 3
        return $webserver;
45
    }
46
}
47