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