SimpleHandler::draw()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Kaloa\Renderer\Inigo\Handler;
4
5
use Kaloa\Renderer\Inigo\Handler\ProtoHandler;
6
7
/**
8
 *
9
 */
10
final class SimpleHandler extends ProtoHandler
11
{
12
    /**
13
     *
14
     * @var string
15
     */
16
    private $front;
17
18
    /**
19
     *
20
     * @var string
21
     */
22
    private $back;
23
24
    /**
25
     *
26
     * @param string $name
27
     * @param int $type
28
     * @param string $front
29
     * @param string $back
30
     */
31 18
    public function __construct($name, $type, $front, $back)
32
    {
33 18
        $this->name  = $name;
34 18
        $this->type  = $type;
35 18
        $this->front = $front;
36 18
        $this->back  = $back;
37 18
    }
38
39
    /**
40
     *
41
     * @param array $data
42
     *
43
     * @return string
44
     */
45 5
    public function draw(array $data)
46
    {
47 5
        $ret = '';
0 ignored issues
show
Unused Code introduced by
$ret 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...
48
49 5
        if ($data['front']) {
50 5
            $ret = $this->front;
51 5
        } else {
52 5
            $ret = $this->back;
53
        }
54
55 5
        return $ret;
56
    }
57
}
58