| Conditions | 10 |
| Paths | 1 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 10.0203 |
| 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 |
||
| 25 | 102 | protected function filterIgnoredSpaces(array $parts) : array |
|
| 26 | { |
||
| 27 | 102 | $filtered = \array_reduce( |
|
| 28 | 102 | \array_keys($parts), |
|
| 29 | 102 | function($carry, $key) use ($parts) { |
|
|
|
|||
| 30 | 102 | $cur = $parts[$key]; |
|
| 31 | 102 | $last = ($carry !== null) ? \end($carry) : null; |
|
| 32 | 102 | $next = (count($parts) > $key + 1) ? $parts[$key + 1] : null; |
|
| 33 | 102 | if ($last !== null && $next !== null && $cur->isSpace && ( |
|
| 34 | 102 | $last->canIgnoreSpacesAfter |
|
| 35 | 102 | && $next->canIgnoreSpacesBefore |
|
| 36 | 102 | && $last instanceof MimeToken |
|
| 37 | 102 | && $next instanceof MimeToken |
|
| 38 | )) { |
||
| 39 | return $carry; |
||
| 40 | } |
||
| 41 | 102 | return \array_merge($carry ?? [], [$cur]); |
|
| 42 | 102 | } |
|
| 43 | 102 | ); |
|
| 44 | 102 | return $filtered; |
|
| 45 | } |
||
| 47 |