Completed
Push — master ( 695906...a2e16e )
by WEBEWEB
19:00
created

BadgeTwigExtension::bootstrapBadgeFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the bootstrap-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
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 WBW\Bundle\BootstrapBundle\Twig\Extension\Component;
13
14
use Twig_SimpleFunction;
15
use WBW\Library\Core\Argument\ArrayHelper;
16
17
/**
18
 * Badge component Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
22
 * @link https://getbootstrap.com/docs/3.3/components/#badges
23
 */
24
class BadgeTwigExtension extends AbstractBadgeTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.badge";
32
33
    /**
34
     * Displays a Bootstrap badge.
35
     *
36
     * @param array $args The arguments.
37
     * @return string Returns the Bootstrap badge.
38
     */
39
    public function bootstrapBadgeFunction(array $args = []) {
40
        return $this->bootstrapBadge(ArrayHelper::get($args, "content"));
41
    }
42
43
    /**
44
     * Get the Twig functions.
45
     *
46
     * @return Twig_SimpleFunction[] Returns the Twig functions.
47
     */
48
    public function getFunctions() {
49
        return [
50
            new Twig_SimpleFunction("bootstrapBadge", [$this, "bootstrapBadgeFunction"], ["is_safe" => ["html"]]),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
51
            new Twig_SimpleFunction("bsBadge", [$this, "bootstrapBadgeFunction"], ["is_safe" => ["html"]]),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFunction has been deprecated with message: since Twig 2.7, use "Twig\TwigFunction" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
52
        ];
53
    }
54
}
55