Completed
Pull Request — 2.x (#43)
by jake
02:49 queued 50s
created

AnchorRaw::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0046

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.4285
cc 1
eloc 6
nc 1
nop 3
crap 1.0046
1
<?php
2
/**
3
 *
4
 * This file is part of Aura for PHP.
5
 *
6
 * @license http://opensource.org/licenses/bsd-license.php BSD
7
 *
8
 */
9
namespace Aura\Html\Helper;
10
11
/**
12
 *
13
 * Helper to generate `<a ... />` tags without escaping the $text param.
14
 *
15
 * @package Aura.Html
16
 *
17
 */
18
class AnchorRaw extends AbstractHelper
19
{
20
    /**
21
     *
22
     * Returns an anchor tag with text left unescaped.
23
     *
24
     * @param string $href The anchor href specification.
25
     *
26
     * @param string $text The text for the anchor.
27
     *
28
     * @param array $attr Attributes for the anchor.
29
     *
30
     * @return string
31
     *
32
     */
33 2
    public function __invoke($href, $text, array $attr = array())
34
    {
35
        $base = array(
36
            'href' => $href,
37 2
        );
38
39 2
        unset($attr['href']);
40
41
        $attr = $this->escaper->attr(array_merge($base, $attr));
42 2
        return "<a $attr>$text</a>";
43 2
    }
44
}
45