| Conditions | 10 |
| Paths | 10 |
| Total Lines | 48 |
| Code Lines | 18 |
| 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 |
||
| 19 | public function parseSymbol(FormatToken $token, FormatParserInterface $parser) |
||
| 20 | { |
||
| 21 | if ($token->isOne('a', 'A')) { |
||
| 22 | // a Lowercase Ante meridiem and Post meridiem am or pm |
||
| 23 | // A Uppercase Ante meridiem and Post meridiem AM or PM |
||
| 24 | return new PregChoice($token, ['am', 'pm']); |
||
| 25 | } |
||
| 26 | |||
| 27 | if ($token->is('B')) { |
||
| 28 | // B Swatch Internet time 000 through 999 |
||
| 29 | return new PregSimple($token, '\d\d\d'); |
||
| 30 | } |
||
| 31 | |||
| 32 | if ($token->isOne('g', 'G')) { |
||
| 33 | // g 12-hour format of an hour without leading zeros 1 through 12 |
||
| 34 | // G 24-hour format of an hour without leading zeros 0 through 23 |
||
| 35 | return new PregSimple($token, '\d?\d'); |
||
| 36 | } |
||
| 37 | |||
| 38 | if ($token->isOne('h', 'H')) { |
||
| 39 | // h 12-hour format of an hour with leading zeros 01 through 12 |
||
| 40 | // H 24-hour format of an hour with leading zeros 00 through 23 |
||
| 41 | return new PregSimple($token, '\d\d'); |
||
| 42 | } |
||
| 43 | |||
| 44 | if ($token->is('i')) { |
||
| 45 | // i Minutes with leading zeros 00 to 59 |
||
| 46 | return new PregSimple($token, '\d\d'); |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($token->is('s')) { |
||
| 50 | // s Seconds, with leading zeros 00 through 59 |
||
| 51 | return new PregSimple($token, '\d\d'); |
||
| 52 | } |
||
| 53 | |||
| 54 | if ($token->is('u')) { |
||
| 55 | // u Microseconds |
||
| 56 | return new PregSimple($token, '\d{6}'); |
||
| 57 | } |
||
| 58 | |||
| 59 | if ($token->is('v')) { |
||
| 60 | // u Milliseconds |
||
| 61 | return new PregSimple($token, '\d\d\d'); |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($token->is('µ')) { |
||
| 65 | // Remaining microseconds |
||
| 66 | return new PregSimple($token, '\d\d\d'); |
||
| 67 | } |
||
| 70 |