CodeTwigExtension::getFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\CSS;
13
14
use Twig\TwigFunction;
15
use WBW\Library\Core\Argument\Helper\ArrayHelper;
16
17
/**
18
 * Code Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\CSS
22
 * @link https://getbootstrap.com/docs/3.3/css/#code
23
 */
24
class CodeTwigExtension extends AbstractCodeTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "wbw.bootstrap.twig.extension.css.code";
32
33
    /**
34
     * Displays a Bootstrap basic block.
35
     *
36
     * @param array $args The arguments.
37
     * @return string Returns the Bootstrap basic block.
38
     */
39
    public function bootstrapBasicBlockFunction(array $args = []): string {
40
        return $this->bootstrapBasicBlock(ArrayHelper::get($args, "content"));
41
    }
42
43
    /**
44
     * Displays a Bootstrap inline.
45
     *
46
     * @param array $args The arguments.
47
     * @return string Returns the Bootstrap inline.
48
     */
49
    public function bootstrapInlineFunction(array $args = []): string {
50
        return $this->bootstrapInline(ArrayHelper::get($args, "content"));
51
    }
52
53
    /**
54
     * Displays a Bootstrap sample output.
55
     *
56
     * @param array $args The arguments.
57
     * @return string Returns the Bootstrap smaple output.
58
     */
59
    public function bootstrapSampleOutputFunction(array $args = []): string {
60
        return $this->bootstrapSampleOutput(ArrayHelper::get($args, "content"));
61
    }
62
63
    /**
64
     * Displays a Bootstrap user input.
65
     *
66
     * @param array $args The arguments.
67
     * @return string Returns the Bootstrap user input.
68
     */
69
    public function bootstrapUserInputFunction(array $args = []): string {
70
        return $this->bootstrapUserInput(ArrayHelper::get($args, "content"));
71
    }
72
73
    /**
74
     * Displays a Bootstrap variable.
75
     *
76
     * @param array $args The arguments.
77
     * @return string Returns the Bootstrap variable.
78
     */
79
    public function bootstrapVariableFunction(array $args = []): string {
80
        return $this->bootstrapVariable(ArrayHelper::get($args, "content"));
81
    }
82
83
    /**
84
     * Get the Twig functions.
85
     *
86
     * @return TwigFunction[] Returns the Twig functions.
87
     */
88
    public function getFunctions(): array {
89
        return [
90
            new TwigFunction("bootstrapBasicBlock", [$this, "bootstrapBasicBlockFunction"], ["is_safe" => ["html"]]),
91
            new TwigFunction("bsBasicBlock", [$this, "bootstrapBasicBlockFunction"], ["is_safe" => ["html"]]),
92
93
            new TwigFunction("bootstrapInline", [$this, "bootstrapInlineFunction"], ["is_safe" => ["html"]]),
94
            new TwigFunction("bsInline", [$this, "bootstrapInlineFunction"], ["is_safe" => ["html"]]),
95
96
            new TwigFunction("bootstrapSampleOutput", [$this, "bootstrapSampleOutputFunction"], ["is_safe" => ["html"]]),
97
            new TwigFunction("bsSampleOutput", [$this, "bootstrapSampleOutputFunction"], ["is_safe" => ["html"]]),
98
99
            new TwigFunction("bootstrapUserInput", [$this, "bootstrapUserInputFunction"], ["is_safe" => ["html"]]),
100
            new TwigFunction("bsUserInput", [$this, "bootstrapUserInputFunction"], ["is_safe" => ["html"]]),
101
102
            new TwigFunction("bootstrapVariable", [$this, "bootstrapVariableFunction"], ["is_safe" => ["html"]]),
103
            new TwigFunction("bsVariable", [$this, "bootstrapVariableFunction"], ["is_safe" => ["html"]]),
104
        ];
105
    }
106
}
107