Code Duplication    Length = 30-30 lines in 2 locations

application/modules/mod_stats/models/attendance_model.php 1 location

@@ 163-192 (lines=30) @@
160
        return false;
161
    }
162
163
    protected function getUrl($id, $type) {
164
        $urlConfiguration = \core\src\CoreFactory::getConfiguration()->getUrlRules();
165
        $url              = \core\models\RouteQuery::create()->filterByEntityId($id)->filterByType($type)->findOneOrCreate();
166
        if ($type == \core\models\Route::TYPE_SHOP_CATEGORY) {
167
            if ($urlConfiguration['shop_category']['parent'] === '1') {
168
                $url = $url->getFullUrl();
169
            } else {
170
                $url = $url->getUrl();
171
            }
172
            if ($urlConfiguration['shop_category']['prefix'] != '') {
173
                $url = rtrim($urlConfiguration['shop_category']['prefix'], '/') . '/' . $url;
174
            }
175
176
            return $url;
177
        } elseif ($type == \core\models\Route::TYPE_PRODUCT) {
178
            if ($urlConfiguration['product']['parent'] === '1') {
179
                $url = $url->getFullUrl();
180
            } else {
181
                $url = $url->getUrl();
182
            }
183
            if ($urlConfiguration['product']['prefix'] != '') {
184
                $url = rtrim($urlConfiguration['product']['prefix'], '/') . '/' . $url;
185
            }
186
187
            return $url;
188
        } else {
189
            return $url->getFullUrl();
190
        }
191
192
    }
193
194
    /**
195
     * Dynamic of categories attendance

application/modules/mod_stats/models/custom_model.php 1 location

@@ 128-157 (lines=30) @@
125
        return false;
126
    }
127
128
    protected function getUrl($id, $type) {
129
        $urlConfiguration = CoreFactory::getConfiguration()->getUrlRules();
130
        $url              = RouteQuery::create()->filterByEntityId($id)->filterByType($type)->findOneOrCreate();
131
        if ($type == Route::TYPE_SHOP_CATEGORY) {
132
            if ($urlConfiguration['shop_category']['parent'] === '1') {
133
                $url = $url->getFullUrl();
134
            } else {
135
                $url = $url->getUrl();
136
            }
137
            if ($urlConfiguration['shop_category']['prefix'] != '') {
138
                $url = rtrim($urlConfiguration['shop_category']['prefix'], '/') . '/' . $url;
139
            }
140
141
            return $url;
142
        } elseif ($type == Route::TYPE_PRODUCT) {
143
            if ($urlConfiguration['product']['parent'] === '1') {
144
                $url = $url->getFullUrl();
145
            } else {
146
                $url = $url->getUrl();
147
            }
148
            if ($urlConfiguration['product']['prefix'] != '') {
149
                $url = rtrim($urlConfiguration['product']['prefix'], '/') . '/' . $url;
150
            }
151
152
            return $url;
153
        } else {
154
            return $url->getFullUrl();
155
        }
156
157
    }
158
159
    protected function getCategoryUrl($id) {
160
        $res = $this->db->select(