Conditions | 4 |
Paths | 5 |
Total Lines | 70 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
185 | public function visible( array $catIds ) |
||
186 | { |
||
187 | if( empty( $catIds ) ) { |
||
188 | return $this; |
||
189 | } |
||
190 | |||
191 | $config = $this->getContext()->getConfig(); |
||
192 | |||
193 | $expr = [ |
||
194 | $this->filter->compare( '==', 'catalog.parentid', $catIds ), |
||
195 | $this->filter->compare( '==', 'catalog.id', $catIds ) |
||
196 | ]; |
||
197 | |||
198 | /** controller/frontend/catalog/levels-always |
||
199 | * The number of levels in the category tree that should be always displayed |
||
200 | * |
||
201 | * Usually, only the root node and the first level of the category |
||
202 | * tree is shown in the frontend. Only if the user clicks on a |
||
203 | * node in the first level, the page reloads and the sub-nodes of |
||
204 | * the chosen category are rendered as well. |
||
205 | * |
||
206 | * Using this configuration option you can enforce the given number |
||
207 | * of levels to be always displayed. The root node uses level 0, the |
||
208 | * categories below level 1 and so on. |
||
209 | * |
||
210 | * In most cases you can set this value via the administration interface |
||
211 | * of the shop application. In that case you often can configure the |
||
212 | * levels individually for each catalog filter. |
||
213 | * |
||
214 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
215 | * client/html/catalog/filter/tree/levels-always |
||
216 | * |
||
217 | * @param integer Number of tree levels |
||
218 | * @since 2019.04 |
||
219 | * @category User |
||
220 | * @category Developer |
||
221 | * @see controller/frontend/catalog/levels-only |
||
222 | */ |
||
223 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { |
||
224 | $expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
225 | } |
||
226 | |||
227 | /** controller/frontend/catalog/levels-only |
||
228 | * No more than this number of levels in the category tree should be displayed |
||
229 | * |
||
230 | * If the user clicks on a category node, the page reloads and the |
||
231 | * sub-nodes of the chosen category are rendered as well. |
||
232 | * Using this configuration option you can enforce that no more than |
||
233 | * the given number of levels will be displayed at all. The root |
||
234 | * node uses level 0, the categories below level 1 and so on. |
||
235 | * |
||
236 | * In most cases you can set this value via the administration interface |
||
237 | * of the shop application. In that case you often can configure the |
||
238 | * levels individually for each catalog filter. |
||
239 | * |
||
240 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
241 | * client/html/catalog/filter/tree/levels-only |
||
242 | * |
||
243 | * @param integer Number of tree levels |
||
244 | * @since 2014.03 |
||
245 | * @category User |
||
246 | * @category Developer |
||
247 | * @see controller/frontend/catalog/levels-always |
||
248 | */ |
||
249 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { |
||
250 | $this->conditions[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
251 | } |
||
252 | |||
253 | $this->conditions[] = $this->filter->combine( '||', $expr ); |
||
254 | return $this; |
||
255 | } |
||
257 |