| Conditions | 1 |
| Paths | 1 |
| Total Lines | 58 |
| Code Lines | 30 |
| 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 namespace norsys\score\composer\depedency\version\semver\converter\toString; |
||
| 52 | function recipientOfSemverVersionAsStringIs(semver $semver, php\string\recipient $recipient) :void |
||
| 53 | { |
||
| 54 | ( |
||
| 55 | new trampoline\container\fifo( |
||
| 56 | new trampoline\functor( |
||
| 57 | function($block) use ($semver) |
||
| 58 | { |
||
| 59 | $this |
||
| 60 | ->recipientOfMajorInSemverVersionAsStringIs( |
||
| 61 | $semver, |
||
| 62 | new php\string\recipient\block($block) |
||
| 63 | ) |
||
| 64 | ; |
||
| 65 | } |
||
| 66 | ), |
||
| 67 | new trampoline\functor( |
||
| 68 | function($block) use ($semver) |
||
| 69 | { |
||
| 70 | $this |
||
| 71 | ->recipientOfMinorInSemverVersionAsStringIs( |
||
| 72 | $semver, |
||
| 73 | new php\string\recipient\block($block) |
||
| 74 | ) |
||
| 75 | ; |
||
| 76 | } |
||
| 77 | ), |
||
| 78 | new trampoline\functor( |
||
| 79 | function($block) use ($semver) |
||
| 80 | { |
||
| 81 | $this |
||
| 82 | ->recipientOfPatchInSemverVersionAsStringIs( |
||
| 83 | $semver, |
||
| 84 | new php\string\recipient\block($block) |
||
| 85 | ) |
||
| 86 | ; |
||
| 87 | } |
||
| 88 | ) |
||
| 89 | ) |
||
| 90 | ) |
||
| 91 | ->argumentsForBlockAre( |
||
| 92 | new php\block\functor( |
||
| 93 | function($recipient, $major, $minor, $patch) |
||
| 94 | { |
||
| 95 | ( |
||
| 96 | new php\string\operator\unary\join( |
||
| 97 | $major, |
||
| 98 | $minor, |
||
| 99 | $patch |
||
| 100 | ) |
||
| 101 | ) |
||
| 102 | ->recipientOfStringOperationWithStringIs( |
||
| 103 | '.', |
||
| 104 | $recipient |
||
| 105 | ) |
||
| 106 | ; |
||
| 107 | } |
||
| 108 | ), |
||
| 109 | $recipient |
||
| 110 | ) |
||
| 114 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.