| Conditions | 11 |
| Paths | 11 |
| Total Lines | 36 |
| Code Lines | 28 |
| 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 |
||
| 57 | public static function normalizeNetwork($network, $testnet) { |
||
| 58 | switch (strtolower($network)) { |
||
| 59 | case 'btc': |
||
| 60 | case 'bitcoin': |
||
| 61 | $network = 'bitcoin'; |
||
| 62 | break; |
||
| 63 | |||
| 64 | case 'tbtc': |
||
| 65 | case 'bitcoin-testnet': |
||
| 66 | $network = 'bitcoin'; |
||
| 67 | $testnet = true; |
||
| 68 | break; |
||
| 69 | case 'bcc': |
||
| 70 | case 'bitcoincash': |
||
| 71 | $network = 'bitcoincash'; |
||
| 72 | break; |
||
| 73 | |||
| 74 | case 'tbcc': |
||
| 75 | case 'bitcoincash-testnet': |
||
| 76 | $network = 'bitcoincash'; |
||
| 77 | $testnet = true; |
||
| 78 | break; |
||
| 79 | |||
| 80 | case 'rbtc': |
||
| 81 | case 'bitcoin-regtest': |
||
| 82 | $network = 'bitcoin'; |
||
| 83 | $testnet = true; |
||
| 84 | break; |
||
| 85 | |||
| 86 | default: |
||
| 87 | throw new \Exception("Unknown network [{$network}]"); |
||
| 88 | // this comment silences a phpcs error. |
||
| 89 | } |
||
| 90 | |||
| 91 | return [$network, $testnet]; |
||
| 92 | } |
||
| 93 | |||
| 118 |