| Conditions | 29 |
| Paths | 29 |
| Total Lines | 40 |
| Code Lines | 32 |
| 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 |
||
| 30 | public static function isValidDelimiter(string $c): bool |
||
| 31 | { |
||
| 32 | if (\mb_strlen($c) > 1) { |
||
| 33 | return false; |
||
| 34 | } |
||
| 35 | |||
| 36 | switch ($c) { |
||
| 37 | // Basic Delimiters. |
||
| 38 | case '/': |
||
| 39 | case '.': |
||
| 40 | case '!': |
||
| 41 | case ',': |
||
| 42 | case ';': |
||
| 43 | case '?': |
||
| 44 | case ' ': |
||
| 45 | case '=': |
||
| 46 | case "'": |
||
| 47 | case '"': |
||
| 48 | case "\t": |
||
| 49 | case "\r": |
||
| 50 | case "\n": |
||
| 51 | // Extra Delimiters. |
||
| 52 | case '[': |
||
| 53 | case ']': |
||
| 54 | case '{': |
||
| 55 | case '}': |
||
| 56 | case '(': |
||
| 57 | case ')': |
||
| 58 | case '&': |
||
| 59 | case '|': |
||
| 60 | case "\\": |
||
| 61 | case '-': |
||
| 62 | case '_': |
||
| 63 | case '+': |
||
| 64 | case '*': |
||
| 65 | case ':': |
||
| 66 | return true; |
||
| 67 | } |
||
| 68 | |||
| 69 | return false; |
||
| 70 | } |
||
| 107 |