Code Duplication    Length = 20-22 lines in 2 locations

class/page.php 2 locations

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