Completed
Push — master ( 4d5688...be014c )
by WEBEWEB
01:51
created

NavTwigExtension::bootstrapNavsJustified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\Component;
13
14
use Twig_SimpleFunction;
15
use WBW\Library\Core\Argument\ArrayHelper;
16
17
/**
18
 * Nav component Twig extension.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component
22
 * @link https://getbootstrap.com/docs/3.3/components/#nav
23
 */
24
class NavTwigExtension extends AbstractNavTwigExtension {
25
26
    /**
27
     * Service name.
28
     *
29
     * @var string
30
     */
31
    const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.nav";
32
33
    /**
34
     * Displays a Bootstrap navs "Justified".
35
     *
36
     * @param array $args The arguments.
37
     * @return string Returns the Bootstrap nav "Justified".
38
     */
39
    public function bootstrapNavsJustified(array $args = []) {
40
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-justified", false);
41
    }
42
43
    /**
44
     * Displays a Bootstrap navs "Pills".
45
     *
46
     * @param array $args The arguments.
47
     * @return string Returns the Bootstrap nav "Pills".
48
     */
49
    public function bootstrapNavsPills(array $args = []) {
50
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-pills", ArrayHelper::get($args, "stacked", false));
51
    }
52
53
    /**
54
     * Displays a Bootstrap navs "Tabs".
55
     *
56
     * @param array $args The arguments.
57
     * @return string Returns the Bootstrap nav "Tabs".
58
     */
59
    public function bootstrapNavsTabs(array $args = []) {
60
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-tabs", false);
61
    }
62
63
    /**
64
     * Get the Twig functions.
65
     *
66
     * @return Twig_SimpleFunction[] Returns the Twig functions.
67
     */
68
    public function getFunctions() {
69
        return [
70
            new Twig_SimpleFunction("bootstrapNavsJustified", [$this, "bootstrapNavsJustifiedFunction"], ["is_safe" => ["html"]]),
71
            new Twig_SimpleFunction("bsNavsJustified", [$this, "bootstrapNavsJustifiedFunction"], ["is_safe" => ["html"]]),
72
73
            new Twig_SimpleFunction("bootstrapNavsPills", [$this, "bootstrapNavsPillsFunction"], ["is_safe" => ["html"]]),
74
            new Twig_SimpleFunction("bsNavsPills", [$this, "bootstrapNavsPillsFunction"], ["is_safe" => ["html"]]),
75
76
            new Twig_SimpleFunction("bootstrapNavsTabs", [$this, "bootstrapNavsTabsFunction"], ["is_safe" => ["html"]]),
77
            new Twig_SimpleFunction("bsNavsTabs", [$this, "bootstrapNavsTabsFunction"], ["is_safe" => ["html"]]),
78
        ];
79
    }
80
}
81