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

Extension/Component/GlyphiconTwigExtension.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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\Bundle\CoreBundle\Renderer\IconRendererInterface;
16
use WBW\Library\Core\Argument\ArrayHelper;
17
18
/**
19
 * Glyphicon Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
23
 * @link https://getbootstrap.com/docs/3.3/components/#glyphicons
24
 */
25
class GlyphiconTwigExtension extends AbstractGlyphiconTwigExtension implements IconRendererInterface {
26
27
    /**
28
     * Service name.
29
     *
30
     * @var string
31
     */
32
    const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.glyphicon";
33
34
    /**
35
     * Displays a Bootstrap glyphicon.
36
     *
37
     * @param array $args The arguments.
38
     * @return string Returns the Bootstrap glyphicon.
39
     */
40
    public function bootstrapGlyphiconFunction(array $args = []) {
41
        return $this->bootstrapGlyphicon(ArrayHelper::get($args, "name", "home"), ArrayHelper::get($args, "style"));
42
    }
43
44
    /**
45
     * Get the Twig functions.
46
     *
47
     * @return Twig_SimpleFunction[] Returns the Twig functions.
48
     */
49
    public function getFunctions() {
50
        return [
51
            new Twig_SimpleFunction("bootstrapGlyphicon", [$this, "bootstrapGlyphiconFunction"], ["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
            new Twig_SimpleFunction("bsGlyphicon", [$this, "bootstrapGlyphiconFunction"], ["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...
53
        ];
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function renderIcon($name, $style) {
60
        return $this->bootstrapGlyphiconFunction(["name" => $name, "style" => $style]);
61
    }
62
}
63