getFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\Assets;
13
14
use Twig\TwigFilter;
15
use Twig\TwigFunction;
16
use WBW\Bundle\CoreBundle\Factory\IconFactory;
17
use WBW\Library\Symfony\Renderer\Assets\IconRendererInterface;
18
19
/**
20
 * Material Design Iconic Font Twig extension.
21
 *
22
 * @author webeweb <https://github.com/webeweb>
23
 * @package WBW\Bundle\CoreBundle\Twig\Extension\Assets
24
 */
25
class MaterialDesignIconicFontTwigExtension extends AbstractMaterialDesignIconicFontTwigExtension implements IconRendererInterface {
26
27
    /**
28
     * Service name.
29
     *
30
     * @var string
31
     */
32
    const SERVICE_NAME = "wbw.core.twig.extension.assets.material_design_iconic_font";
33
34
    /**
35
     * Get the Twig filters.
36
     *
37
     * @return TwigFilter[] Returns the Twig filters.
38
     */
39
    public function getFilters(): array {
40
41
        return [
42
            new TwigFilter("materialDesignIconicFontList", [$this, "materialDesignIconicFontListFilter"], ["is_safe" => ["html"]]),
43
            new TwigFilter("mdiFontList", [$this, "materialDesignIconicFontListFilter"], ["is_safe" => ["html"]]),
44
45
            new TwigFilter("materialDesignIconicFontListIcon", [$this, "materialDesignIconicFontListIconFilter"], ["is_safe" => ["html"]]),
46
            new TwigFilter("mdiFontListIcon", [$this, "materialDesignIconicFontListIconFilter"], ["is_safe" => ["html"]]),
47
        ];
48
    }
49
50
    /**
51
     * Get the Twig functions.
52
     *
53
     * @return TwigFunction[] Returns the Twig functions.
54
     */
55
    public function getFunctions(): array {
56
57
        return [
58
            new TwigFunction("materialDesignIconicFontIcon", [$this, "materialDesignIconicFontIconFunction"], ["is_safe" => ["html"]]),
59
            new TwigFunction("mdiIcon", [$this, "materialDesignIconicFontIconFunction"], ["is_safe" => ["html"]]),
60
        ];
61
    }
62
63
    /**
64
     * Display a Material Design Iconic Font icon.
65
     *
66
     * @param array $args The arguments.
67
     * @return string Returns the Material Design Iconic Font icon.
68
     */
69
    public function materialDesignIconicFontIconFunction(array $args = []): string {
70
        return $this->materialDesignIconicFontIcon(IconFactory::parseMaterialDesignIconicFontIcon($args));
71
    }
72
73
    /**
74
     * Display a Material Design Iconic Font list.
75
     *
76
     * @param array|string $items The items.
77
     * @return string Returns the Material Design Iconic Font list.
78
     */
79
    public function materialDesignIconicFontListFilter($items): string {
80
        return $this->materialDesignIconicFontList($items);
81
    }
82
83
    /**
84
     * Display a Material Design Iconic Font list icon.
85
     *
86
     * @param string $icon The icon.
87
     * @param string|null $content The content.
88
     * @return string Returns the Material Design Iconic Font list icon.
89
     */
90
    public function materialDesignIconicFontListIconFilter(string $icon, ?string $content): string {
91
        return $this->materialDesignIconicFontListIcon($icon, $content);
92
    }
93
94
    /**
95
     * {@inheritDoc}
96
     */
97
    public function renderIcon(?string $name, ?string $style): string {
98
        return $this->materialDesignIconicFontIconFunction(["name" => $name, "style" => $style]);
99
    }
100
}
101