UrlHandler::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Kaloa\Renderer\Inigo\Handler;
4
5
use Kaloa\Renderer\Inigo\Handler\ProtoHandler;
6
use Kaloa\Renderer\Inigo\Parser;
7
8
/**
9
 *
10
 */
11
final class UrlHandler extends ProtoHandler
12
{
13
    /**
14
     *
15
     */
16 18
    public function __construct()
17
    {
18 18
        $this->name = 'url|link';
19 18
        $this->type = Parser::TAG_INLINE;
20 18
        $this->defaultParam = 'href';
21 18
    }
22
23
    /**
24
     *
25
     * @param  array  $data
26
     * @return string
27
     */
28 4
    public function draw(array $data)
29
    {
30 4
        $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...
31
32 4
        if ($data['front']) {
33 4
            $href = $this->fillParam($data, 'href', '');
34
35 4
            $title = $this->fillParam($data, 'title', null);
36
37 4
            if ($title !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
38 1
                $title = ' title="' . $this->e($title) . '"';
39 1
            } else {
40 4
                $title = ' title="Open &quot;' . $this->e($href) . '&quot;"';
41
            }
42
43 4
            $ret = '<a href="' . $this->e($href) . '"' . $title . '>';
44 4
        } else {
45 4
            $ret = '</a>';
46
        }
47
48 4
        return $ret;
49
    }
50
}
51