Completed
Push — master ( 67c65c...9a618a )
by WEBEWEB
06:47
created

InlineCodeTwigExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A bootstrapInlineFunction() 0 3 1
A getFunctions() 0 5 1
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\Code;
13
14
use Twig_SimpleFunction;
15
use WBW\Library\Core\Utility\ArrayUtility;
16
17
/**
18
 * Inline code Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Code
22
 * @final
23
 */
24
final class InlineCodeTwigExtension extends AbstractCodeTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.code.inline";
32
33
    /**
34
     * Constructor.
35
     */
36
    public function __construct() {
37
        parent::__construct();
38
    }
39
40
    /**
41
     * Displays a Bootstrap inline.
42
     *
43
     * @param array $args The arguments.
44
     * @return string Returns the Bootstrap inline.
45
     */
46
    public function bootstrapInlineFunction(array $args = []) {
47
        return $this->bootstrapInline(ArrayUtility::get($args, "content"));
48
    }
49
50
    /**
51
     * Get the Twig functions.
52
     *
53
     * @return array Returns the Twig functions.
54
     */
55
    public function getFunctions() {
56
        return [
57
            new Twig_SimpleFunction("bootstrapInline", [$this, "bootstrapInlineFunction"], ["is_safe" => ["html"]]),
58
        ];
59
    }
60
61
}
62