Completed
Push — master ( 21a652...46e8b2 )
by WEBEWEB
01:49
created

NavTwigExtension::bootstrapNavTabs()   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\Helper\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
     * Constructor.
35
     */
36
    public function __construct() {
37
        parent::__construct();
38
    }
39
40
    /**
41
     * Displays a Bootstrap navs "Justified".
42
     *
43
     * @param array $args The arguments.
44
     * @return string Returns the Bootstrap nav "Justified".
45
     */
46
    public function bootstrapNavsJustified(array $args = []) {
47
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-justified", false);
48
    }
49
50
    /**
51
     * Displays a Bootstrap navs "Pills".
52
     *
53
     * @param array $args The arguments.
54
     * @return string Returns the Bootstrap nav "Pills".
55
     */
56
    public function bootstrapNavsPills(array $args = []) {
57
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-pills", ArrayHelper::get($args, "stacked", false));
58
    }
59
60
    /**
61
     * Displays a Bootstrap navs "Tabs".
62
     *
63
     * @param array $args The arguments.
64
     * @return string Returns the Bootstrap nav "Tabs".
65
     */
66
    public function bootstrapNavsTabs(array $args = []) {
67
        return $this->bootstrapNavs(ArrayHelper::get($args, "items", []), "nav-tabs", false);
68
    }
69
70
    /**
71
     * Get the Twig functions.
72
     *
73
     * @return Twig_SimpleFunction[] Returns the Twig functions.
74
     */
75
    public function getFunctions() {
76
        return [
77
            new Twig_SimpleFunction("bootstrapNavsJustified", [$this, "bootstrapNavsJustifiedFunction"], ["is_safe" => ["html"]]),
78
            new Twig_SimpleFunction("bootstrapNavsPills", [$this, "bootstrapNavsPillsFunction"], ["is_safe" => ["html"]]),
79
            new Twig_SimpleFunction("bootstrapNavsTabs", [$this, "bootstrapNavsTabsFunction"], ["is_safe" => ["html"]]),
80
        ];
81
    }
82
83
}
84