SideNavHelpers   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 18.64 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 11
loc 59
rs 10
c 1
b 0
f 0
wmc 6
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hasSub() 0 9 2
A itemIcon() 11 11 2
A new_tab() 0 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * SideNav helper methods
5
 *
6
 * @author Alireza Josheghani <[email protected]>
7
 * @version 1.0
8
 * @package SideNav
9
 * @since 8 Oct 2016
10
 */
11
12
namespace Anetwork\SideNav;
13
14
trait SideNavHelpers
15
{
16
17
    /**
18
     * Check menu has sub
19
     *
20
     * @author Alireza Josheghani <[email protected]>
21
     * @since  8 Oct 2016
22
     * @param  $menu
23
     * @return bool
24
     */
25
    public static function hasSub($menu)
26
    {
27
        // check menu has sub
28
        if(! empty($menu['sub'])) {
29
            return true;
30
        }
31
32
        return false;
33
    }
34
35
    /**
36
     * Print item icon
37
     *
38
     * @author Alireza Josheghani <[email protected]>
39
     * @since  8 Oct 2016
40
     * @param  $value
41
     * @return string
42
     */
43 View Code Duplication
    public static function itemIcon($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
46
        $tag = $value['tag'];
47
48
        if($value['tag'] === null) {
49
            $tag = 'i';
50
        }
51
52
        return '<' . $tag . ' class="' . $value['value'] . '"></' . $tag . '>';
53
    }
54
55
    /**
56
     * Print item new_tab option
57
     *
58
     * @author Alireza Josheghani <[email protected]>
59
     * @since  8 Oct 2016
60
     * @param  $newTab
61
     * @return null|string
62
     */
63
    public static function new_tab($newTab)
64
    {
65
        if($newTab) {
66
            return 'target="_blank"';
67
        }
68
69
        return null;
70
    }
71
72
}