Code Duplication    Length = 20-22 lines in 2 locations

class/page.php 2 locations

@@ 100-119 (lines=20) @@
97
     * @param  int        $level
98
     * @return array|bool
99
     */
100
    public function &menuTree($pages = array(), $key = 0, $level = 1)
101
    {
102
        if (!is_array($pages) || 0 === count($pages)) {
103
            return false;
104
        }
105
        $menu = array();
106
107
        foreach ($pages as $k => $v) {
108
            if ($v['page_pid'] == $key) {
109
                $menu[$k]          = $v;
110
                $menu[$k]['level'] = $level;
111
                $child             = $this->menuTree($pages, $k, $level + 1);
112
                if (!empty($child)) {
113
                    $menu[$k]['child'] = $child;
114
                }
115
            }
116
        }
117
118
        return $menu;
119
    }
120
121
    /**
122
     * @param  array      $pages
@@ 126-147 (lines=22) @@
123
     * @param  int        $key
124
     * @return array|bool
125
     */
126
    public function getBread($pages = array(), $key = 0)
127
    {
128
        if (!is_array($pages) || 0 === count($pages)) {
129
            return false;
130
        }
131
        $bread = array();
132
133
        if (isset($pages[$key])) {
134
            $current = $pages[$key];
135
            $bread   = array($current['page_id'] => $current['page_menu_title']);
136
            if ($current['page_pid'] > 0) {
137
                $p_brend = $this->getBread($pages, $current['page_pid']);
138
                if (!empty($p_brend)) {
139
                    foreach ($p_brend as $k => $v) {
140
                        $bread[$k] = $v;
141
                    }
142
                }
143
            }
144
        }
145
146
        return $bread;
147
    }
148
}
149