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 |
||
202 | public function visible( array $catIds ) : Iface |
||
203 | { |
||
204 | if( empty( $catIds ) ) { |
||
205 | return $this; |
||
206 | } |
||
207 | |||
208 | $config = $this->getContext()->getConfig(); |
||
209 | |||
210 | $expr = [ |
||
211 | $this->filter->compare( '==', 'catalog.parentid', $catIds ), |
||
212 | $this->filter->compare( '==', 'catalog.id', $catIds ) |
||
213 | ]; |
||
214 | |||
215 | /** controller/frontend/catalog/levels-always |
||
216 | * The number of levels in the category tree that should be always displayed |
||
217 | * |
||
218 | * Usually, only the root node and the first level of the category |
||
219 | * tree is shown in the frontend. Only if the user clicks on a |
||
220 | * node in the first level, the page reloads and the sub-nodes of |
||
221 | * the chosen category are rendered as well. |
||
222 | * |
||
223 | * Using this configuration option you can enforce the given number |
||
224 | * of levels to be always displayed. The root node uses level 0, the |
||
225 | * categories below level 1 and so on. |
||
226 | * |
||
227 | * In most cases you can set this value via the administration interface |
||
228 | * of the shop application. In that case you often can configure the |
||
229 | * levels individually for each catalog filter. |
||
230 | * |
||
231 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
232 | * client/html/catalog/filter/tree/levels-always |
||
233 | * |
||
234 | * @param integer Number of tree levels |
||
235 | * @since 2019.04 |
||
236 | * @category User |
||
237 | * @category Developer |
||
238 | * @see controller/frontend/catalog/levels-only |
||
239 | */ |
||
240 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { |
||
241 | $expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
242 | } |
||
243 | |||
244 | /** controller/frontend/catalog/levels-only |
||
245 | * No more than this number of levels in the category tree should be displayed |
||
246 | * |
||
247 | * If the user clicks on a category node, the page reloads and the |
||
248 | * sub-nodes of the chosen category are rendered as well. |
||
249 | * Using this configuration option you can enforce that no more than |
||
250 | * the given number of levels will be displayed at all. The root |
||
251 | * node uses level 0, the categories below level 1 and so on. |
||
252 | * |
||
253 | * In most cases you can set this value via the administration interface |
||
254 | * of the shop application. In that case you often can configure the |
||
255 | * levels individually for each catalog filter. |
||
256 | * |
||
257 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
258 | * client/html/catalog/filter/tree/levels-only |
||
259 | * |
||
260 | * @param integer Number of tree levels |
||
261 | * @since 2014.03 |
||
262 | * @category User |
||
263 | * @category Developer |
||
264 | * @see controller/frontend/catalog/levels-always |
||
265 | */ |
||
266 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { |
||
267 | $this->conditions[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
268 | } |
||
269 | |||
270 | $this->conditions[] = $this->filter->combine( '||', $expr ); |
||
271 | return $this; |
||
272 | } |
||
274 |