Completed
Push — master ( f1be72...53ea25 )
by
unknown
04:23
created

SideNavHelpers::hasSub()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
/**
4
 * @author Alireza Josheghani <[email protected]>
5
 * @version 1.0
6
 * @package SideNav
7
 * @since 8 Oct 2016
8
 * SideNav helper methods
9
 */
10
11
namespace Anetwork\SideNav;
12
13
trait SideNavHelpers {
14
15
    /**
16
     * Check menu has sub
17
     * @author Alireza Josheghani <[email protected]>
18
     * @since 8 Oct 2016
19
     * @param $menu
20
     * @return bool
21
     */
22
    public static function hasSub($menu)
23
    {
24
        // check menu has sub
25
        if(! empty($menu['sub']))
26
            return true;
27
28
        return false;
29
    }
30
31
    /**
32
     * Print item icon
33
     * @author Alireza Josheghani <[email protected]>
34
     * @since 8 Oct 2016
35
     * @param $value
36
     * @return string
37
     */
38
    public static function itemIcon($value)
39
    {
40
41
        $tag = $value['tag'];
42
43
        if($value['tag'] === null)
44
            $tag = 'i';
45
46
        return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>';
47
    }
48
49
    /**
50
     * Print item new_tab option
51
     * @author Alireza Josheghani <[email protected]>
52
     * @since 8 Oct 2016
53
     * @param $newTab
54
     * @return null|string
55
     */
56
    public static function new_tab($newTab)
57
    {
58
        if($newTab)
59
            return 'target="_blank"';
60
61
        return null;
62
    }
63
64
}