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 |
||
174 | public function visible( array $catIds ) |
||
175 | { |
||
176 | if( empty( $catIds ) ) { |
||
177 | return $this; |
||
178 | } |
||
179 | |||
180 | $config = $this->getContext()->getConfig(); |
||
181 | |||
182 | $expr = [ |
||
183 | $this->filter->compare( '==', 'catalog.parentid', $catIds ), |
||
184 | $this->filter->compare( '==', 'catalog.id', $catIds ) |
||
185 | ]; |
||
186 | |||
187 | /** controller/frontend/catalog/levels-always |
||
188 | * The number of levels in the category tree that should be always displayed |
||
189 | * |
||
190 | * Usually, only the root node and the first level of the category |
||
191 | * tree is shown in the frontend. Only if the user clicks on a |
||
192 | * node in the first level, the page reloads and the sub-nodes of |
||
193 | * the chosen category are rendered as well. |
||
194 | * |
||
195 | * Using this configuration option you can enforce the given number |
||
196 | * of levels to be always displayed. The root node uses level 0, the |
||
197 | * categories below level 1 and so on. |
||
198 | * |
||
199 | * In most cases you can set this value via the administration interface |
||
200 | * of the shop application. In that case you often can configure the |
||
201 | * levels individually for each catalog filter. |
||
202 | * |
||
203 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
204 | * client/html/catalog/filter/tree/levels-always |
||
205 | * |
||
206 | * @param integer Number of tree levels |
||
207 | * @since 2019.04 |
||
208 | * @category User |
||
209 | * @category Developer |
||
210 | * @see controller/frontend/catalog/levels-only |
||
211 | */ |
||
212 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-always' ) ) != null ) { |
||
213 | $expr[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
214 | } |
||
215 | |||
216 | /** controller/frontend/catalog/levels-only |
||
217 | * No more than this number of levels in the category tree should be displayed |
||
218 | * |
||
219 | * If the user clicks on a category node, the page reloads and the |
||
220 | * sub-nodes of the chosen category are rendered as well. |
||
221 | * Using this configuration option you can enforce that no more than |
||
222 | * the given number of levels will be displayed at all. The root |
||
223 | * node uses level 0, the categories below level 1 and so on. |
||
224 | * |
||
225 | * In most cases you can set this value via the administration interface |
||
226 | * of the shop application. In that case you often can configure the |
||
227 | * levels individually for each catalog filter. |
||
228 | * |
||
229 | * Note: This setting was available between 2014.03 and 2019.04 as |
||
230 | * client/html/catalog/filter/tree/levels-only |
||
231 | * |
||
232 | * @param integer Number of tree levels |
||
233 | * @since 2014.03 |
||
234 | * @category User |
||
235 | * @category Developer |
||
236 | * @see controller/frontend/catalog/levels-always |
||
237 | */ |
||
238 | if( ( $levels = $config->get( 'controller/frontend/catalog/levels-only' ) ) != null ) { |
||
239 | $this->conditions[] = $this->filter->compare( '<=', 'catalog.level', $levels ); |
||
240 | } |
||
241 | |||
242 | $this->conditions[] = $this->filter->combine( '||', $expr ); |
||
243 | return $this; |
||
244 | } |
||
246 |