BootstrapBadgeExtension::getFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of BraincraftedBootstrapBundle.
4
 *
5
 * (c) 2012-2013 by Florian Eckerstorfer
6
 */
7
8
namespace Braincrafted\Bundle\BootstrapBundle\Twig;
9
10
use Twig_Extension;
11
use Twig_SimpleFunction;
12
13
/**
14
 * BootstrapLabelExtension
15
 *
16
 * @category   TwigExtension
17
 * @package    BraincraftedBootstrapBundle
18
 * @subpackage Twig
19
 * @author     Florian Eckerstorfer <[email protected]>
20
 * @copyright  2012-2013 Florian Eckerstorfer
21
 * @license    http://opensource.org/licenses/MIT The MIT License
22
 * @link       http://bootstrap.braincrafted.com Bootstrap for Symfony2
23
 */
24
class BootstrapBadgeExtension extends Twig_Extension
25
{
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function getFunctions()
30
    {
31
        return array(
32
            new Twig_SimpleFunction(
33
                'badge',
34
                array($this, 'badgeFunction'),
35
                array('pre_escape' => 'html', 'is_safe' => array('html'))
36
            )
37
        );
38
    }
39
40
    /**
41
     * Returns the HTML code for a badge.
42
     *
43
     * @param string $text The text of the badge
44
     *
45
     * @return string The HTML code of the badge
46
     */
47
    public function badgeFunction($text)
48
    {
49
        return sprintf('<span class="badge">%s</span>', $text);
50
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getName()
56
    {
57
        return 'braincrafted_bootstrap_badge';
58
    }
59
}
60