| Conditions | 15 |
| Paths | 60 |
| Total Lines | 28 |
| Code Lines | 21 |
| Lines | 4 |
| Ratio | 14.29 % |
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 |
||
| 113 | private function normalize($str, $opts) { |
||
| 114 | if ($opts['nfc'] || $opts['nfkc']) { |
||
| 115 | if (class_exists('Normalizer', false)) { |
||
| 116 | View Code Duplication | if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
| 117 | $str = Normalizer::normalize($str, Normalizer::FORM_C); |
||
| 118 | View Code Duplication | if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
| 119 | $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
||
| 120 | } else { |
||
| 121 | if (! class_exists('I18N_UnicodeNormalizer', false)) { |
||
| 122 | @ include_once 'I18N/UnicodeNormalizer.php'; |
||
| 123 | } |
||
| 124 | if (class_exists('I18N_UnicodeNormalizer', false)) { |
||
| 125 | $normalizer = new I18N_UnicodeNormalizer(); |
||
| 126 | if ($opts['nfc']) |
||
| 127 | $str = $normalizer->normalize($str, 'NFC'); |
||
| 128 | if ($opts['nfkc']) |
||
| 129 | $str = $normalizer->normalize($str, 'NFKC'); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | } |
||
| 133 | if ($opts['lowercase']) { |
||
| 134 | $str = strtolower($str); |
||
| 135 | } |
||
| 136 | if ($opts['convmap'] && is_array($opts['convmap'])) { |
||
| 137 | $str = strtr($str, $opts['convmap']); |
||
| 138 | } |
||
| 139 | return $str; |
||
| 140 | } |
||
| 141 | } |
||
| 142 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.