| Conditions | 13 |
| Paths | 30 |
| Total Lines | 25 |
| Code Lines | 19 |
| Lines | 4 |
| Ratio | 16 % |
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 |
||
| 110 | private function normalize($str, $opts) { |
||
| 111 | if ($opts['nfc'] || $opts['nfkc']) { |
||
| 112 | if (class_exists('Normalizer')) { |
||
| 113 | View Code Duplication | if ($opts['nfc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_C)) |
|
| 114 | $str = Normalizer::normalize($str, Normalizer::FORM_C); |
||
| 115 | View Code Duplication | if ($opts['nfkc'] && ! Normalizer::isNormalized($str, Normalizer::FORM_KC)) |
|
| 116 | $str = Normalizer::normalize($str, Normalizer::FORM_KC); |
||
| 117 | } else { |
||
| 118 | if (! class_exists('I18N_UnicodeNormalizer')) { |
||
| 119 | @ include_once 'I18N/UnicodeNormalizer.php'; |
||
| 120 | } |
||
| 121 | if (class_exists('I18N_UnicodeNormalizer')) { |
||
| 122 | $normalizer = new I18N_UnicodeNormalizer(); |
||
| 123 | if ($opts['nfc']) |
||
| 124 | $str = $normalizer->normalize($str, 'NFC'); |
||
| 125 | if ($opts['nfkc']) |
||
| 126 | $str = $normalizer->normalize($str, 'NFKC'); |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 | if ($opts['lowercase']) { |
||
| 131 | $str = strtolower($str); |
||
| 132 | } |
||
| 133 | return $str; |
||
| 134 | } |
||
| 135 | } |
||
| 136 |
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.