IconTwigExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 48
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A adminBSBIconBasicFunction() 0 3 1
A adminBSBIconMaterialDesignFunction() 0 3 1
A getFunctions() 0 6 1
A renderIcon() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2017 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\AdminBSBBundle\Twig\Extension\UI;
13
14
use Twig\TwigFunction;
15
use WBW\Bundle\CoreBundle\Renderer\IconRendererInterface;
16
use WBW\Library\Core\Argument\Helper\ArrayHelper;
17
18
/**
19
 * Icon Twig extension.
20
 *
21
 * @author webeweb <https://github.com/webeweb/>
22
 * @package WBW\Bundle\AdminBSBBundle\Twig\Extension\UI
23
 */
24
class IconTwigExtension extends AbstractIconTwigExtension implements IconRendererInterface {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "wbw.adminbsb.twig.extension.ui.icon";
32
33
    /**
34
     * Displays an AdminBSB basic icon.
35
     *
36
     * @param array $args The arguments.
37
     * @return string Returns the AdminBSB basic icon.
38
     */
39
    public function adminBSBIconBasicFunction(array $args = []): string {
40
        return $this->adminBSBIcon(ArrayHelper::get($args, "name"), ArrayHelper::get($args, "style"));
41
    }
42
43
    /**
44
     * Displays an AdminBSB material design icon.
45
     *
46
     * @param array $args The arguments.
47
     * @return string Returns the AdminBSB material design icon.
48
     */
49
    public function adminBSBIconMaterialDesignFunction(array $args = []): string {
50
        return $this->adminBSBIcon(ArrayHelper::get($args, "name"), ArrayHelper::get($args, "style"), static::materialDesignColor(ArrayHelper::get($args, "color"), "col-"));
51
    }
52
53
    /**
54
     * Get the Twig functions.
55
     *
56
     * @return TwigFunction[] Returns the Twig functions.
57
     */
58
    public function getFunctions(): array {
59
        return [
60
            new TwigFunction("adminBSBIconBasic", [$this, "adminBSBIconBasicFunction"], ["is_safe" => ["html"]]),
61
            new TwigFunction("adminBSBIconMaterialDesign", [$this, "adminBSBIconMaterialDesignFunction"], ["is_safe" => ["html"]]),
62
        ];
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68
    public function renderIcon(?string $name, ?string $style): string {
69
        return $this->adminBSBIconBasicFunction(["name" => $name, "style" => $style]);
70
    }
71
}
72