Completed
Push — master ( 4b8173...652bbf )
by WEBEWEB
01:31
created

MeteoconsTwigExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFunctions() 0 5 1
A meteoconsIconFunction() 0 3 1
A renderIcon() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the core-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\CoreBundle\Twig\Extension\Asset;
13
14
use Twig\TwigFunction;
15
use WBW\Bundle\CoreBundle\Renderer\IconRendererInterface;
16
use WBW\Library\Core\Argument\ArrayHelper;
17
18
/**
19
 * Meteocons Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\CoreBundle\Twig\Extension\Asset
23
 */
24
class MeteoconsTwigExtension extends AbstractMeteoconsTwigExtension implements IconRendererInterface {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "wbw.core.twig.extension.asset.meteocons";
32
33
    /**
34
     * Get the Twig functions.
35
     *
36
     * @return TwigFunction[] Returns the Twig functions.
37
     */
38
    public function getFunctions() {
39
        return [
40
            new TwigFunction("meteoconsIcon", [$this, "meteoconsIconFunction"], ["is_safe" => ["html"]]),
41
        ];
42
    }
43
44
    /**
45
     * Displays a Meteocons icon.
46
     *
47
     * @param array $args The arguments.
48
     * @return string Returns a Meteocons icon.
49
     */
50
    public function meteoconsIconFunction(array $args = []) {
51
        return $this->meteoconsIcon(ArrayHelper::get($args, "name", "A"), ArrayHelper::get($args, "style"));
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57
    public function renderIcon($name, $style) {
58
        return $this->meteoconsIconFunction(["name" => $name, "style" => $style]);
59
    }
60
}
61