| Conditions | 15 |
| Paths | 1280 |
| Total Lines | 27 |
| 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 |
||
| 43 | protected function bootstrapGrid($lg, $md, $sm, $xs, $recopy, $prefix) { |
||
| 44 | |||
| 45 | // Initialize the values. |
||
| 46 | $found = null; |
||
| 47 | $values = [&$lg, &$md, &$sm, &$xs]; |
||
| 48 | |||
| 49 | // Handle each value. |
||
| 50 | foreach ($values as &$current) { |
||
| 51 | if (1 <= $current && $current <= 12) { |
||
| 52 | $found = $current; |
||
| 53 | } |
||
| 54 | if (null === $current && true === $recopy && null !== $found) { |
||
| 55 | $current = $found; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | // Initialize the columns. |
||
| 60 | $columns = []; |
||
| 61 | |||
| 62 | $columns[] = 1 <= $lg && $lg <= 12 ? "col-lg-" . $prefix . $lg : null; |
||
| 63 | $columns[] = 1 <= $md && $md <= 12 ? "col-md-" . $prefix . $md : null; |
||
| 64 | $columns[] = 1 <= $sm && $sm <= 12 ? "col-sm-" . $prefix . $sm : null; |
||
| 65 | $columns[] = 1 <= $xs && $xs <= 12 ? "col-xs-" . $prefix . $xs : null; |
||
| 66 | |||
| 67 | // Return the columns. |
||
| 68 | return trim(implode(" ", $columns)); |
||
| 69 | } |
||
| 70 | |||
| 72 |