| Conditions | 15 |
| Paths | 96 |
| Total Lines | 73 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 95 | $minimumWidths = $this->minimumWidths->combine(new ColumnWidths($widths)); |
||
| 96 | |||
| 97 | $calculator = new CalculateWidths(); |
||
| 98 | $dataCellWidths = $calculator->calculateLongestCell($rows); |
||
| 99 | |||
| 100 | $availableWidth = $this->width - $dataCellWidths->paddingSpace($this->paddingInEachCell, $this->extraPaddingAtEndOfLine, $this->extraPaddingAtBeginningOfLine); |
||
| 101 | |||
| 102 | $this->minimumWidths->adjustMinimumWidths($availableWidth, $dataCellWidths); |
||
| 103 | |||
| 104 | return $calculator->calculate($availableWidth, $dataCellWidths, $minimumWidths); |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Wrap one cell. Guard against modifying non-strings and |
||
| 109 | * then call through to wordwrap(). |
||
| 110 | * |
||
| 111 | * @param mixed $cell |
||
| 112 | * @param string $cellWidth |
||
| 113 | * @return mixed |
||
| 114 | */ |
||
| 115 | protected function wrapCell($cell, $cellWidth) |
||
| 116 | { |
||
| 117 | if (!is_string($cell)) { |
||
| 118 | return $cell; |
||
| 119 | } |
||
| 120 | return wordwrap($cell, $cellWidth, "\n", true); |
||
| 121 | } |
||
| 122 | } |
||
| 123 |