| Conditions | 1 |
| Paths | 1 |
| Total Lines | 97 |
| Code Lines | 41 |
| 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 |
||
| 31 | public function localeList(): array |
||
| 32 | { |
||
| 33 | return [ |
||
| 34 | [ |
||
| 35 | 'cs_CZ', |
||
| 36 | [ |
||
| 37 | 'cs_CZ', |
||
| 38 | 'cs', |
||
| 39 | ], |
||
| 40 | ], |
||
| 41 | [ |
||
| 42 | 'sr_CS.UTF-8@latin', |
||
| 43 | [ |
||
| 44 | 'sr_CS.UTF-8@latin', |
||
| 45 | 'sr_CS@latin', |
||
| 46 | 'sr@latin', |
||
| 47 | 'sr_CS.UTF-8', |
||
| 48 | 'sr_CS', |
||
| 49 | 'sr', |
||
| 50 | ], |
||
| 51 | ], |
||
| 52 | // For a locale containing country code, we prefer |
||
| 53 | // full locale name, but if that's not found, fall back |
||
| 54 | // to the language only locale name. |
||
| 55 | [ |
||
| 56 | 'sr_RS', |
||
| 57 | [ |
||
| 58 | 'sr_RS', |
||
| 59 | 'sr', |
||
| 60 | ], |
||
| 61 | ], |
||
| 62 | // If language code is used, it's the only thing returned. |
||
| 63 | [ |
||
| 64 | 'sr', |
||
| 65 | ['sr'], |
||
| 66 | ], |
||
| 67 | // There is support for language and charset only. |
||
| 68 | [ |
||
| 69 | 'sr.UTF-8', |
||
| 70 | [ |
||
| 71 | 'sr.UTF-8', |
||
| 72 | 'sr', |
||
| 73 | ], |
||
| 74 | ], |
||
| 75 | |||
| 76 | // It can also split out character set from the full locale name. |
||
| 77 | [ |
||
| 78 | 'sr_RS.UTF-8', |
||
| 79 | [ |
||
| 80 | 'sr_RS.UTF-8', |
||
| 81 | 'sr_RS', |
||
| 82 | 'sr', |
||
| 83 | ], |
||
| 84 | ], |
||
| 85 | |||
| 86 | // There is support for @modifier in locale names as well. |
||
| 87 | [ |
||
| 88 | 'sr_RS.UTF-8@latin', |
||
| 89 | [ |
||
| 90 | 'sr_RS.UTF-8@latin', |
||
| 91 | 'sr_RS@latin', |
||
| 92 | 'sr@latin', |
||
| 93 | 'sr_RS.UTF-8', |
||
| 94 | 'sr_RS', |
||
| 95 | 'sr', |
||
| 96 | ], |
||
| 97 | ], |
||
| 98 | [ |
||
| 99 | 'sr.UTF-8@latin', |
||
| 100 | [ |
||
| 101 | 'sr.UTF-8@latin', |
||
| 102 | 'sr@latin', |
||
| 103 | 'sr.UTF-8', |
||
| 104 | 'sr', |
||
| 105 | ], |
||
| 106 | ], |
||
| 107 | |||
| 108 | // We can pass in only language and modifier. |
||
| 109 | [ |
||
| 110 | 'sr@latin', |
||
| 111 | [ |
||
| 112 | 'sr@latin', |
||
| 113 | 'sr', |
||
| 114 | ], |
||
| 115 | ], |
||
| 116 | |||
| 117 | // If locale name is not following the regular POSIX pattern, |
||
| 118 | // it's used verbatim. |
||
| 119 | [ |
||
| 120 | 'something', |
||
| 121 | ['something'], |
||
| 122 | ], |
||
| 123 | |||
| 124 | // Passing in an empty string returns an empty array. |
||
| 125 | [ |
||
| 126 | '', |
||
| 127 | [], |
||
| 128 | ], |
||
| 301 |