| Conditions | 4 |
| Paths | 6 |
| Total Lines | 149 |
| Code Lines | 125 |
| 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 |
||
| 157 | function adslight_seo_title($title = '', $withExt = false) |
||
| 158 | { |
||
| 159 | /** |
||
| 160 | * if XOOPS ML is present, let's sanitize the title with the current language |
||
| 161 | */ |
||
| 162 | $myts = \MyTextSanitizer::getInstance(); |
||
| 163 | if (method_exists($myts, 'formatForML')) { |
||
| 164 | $title = $myts->formatForML($title); |
||
| 165 | } |
||
| 166 | |||
| 167 | // Transformation de la chaine en minuscule |
||
| 168 | // Codage de la chaine afin d'�viter les erreurs 500 en cas de caract�res impr�vus |
||
| 169 | $title = rawurlencode(mb_strtolower($title)); |
||
| 170 | |||
| 171 | // Transformation des ponctuations |
||
| 172 | // Tab Space ! " # % & ' ( ) , / : ; < = > ? @ [ \ ] ^ { | } ~ . + |
||
| 173 | $pattern = [ |
||
| 174 | '/%09/', // Tab |
||
| 175 | '/%20/', // Space |
||
| 176 | '/%21/', // ! |
||
| 177 | '/%22/', // " |
||
| 178 | '/%23/', // # |
||
| 179 | '/%25/', // % |
||
| 180 | '/%26/', // & |
||
| 181 | '/%27/', // ' |
||
| 182 | '/%28/', // ( |
||
| 183 | '/%29/', // ) |
||
| 184 | '/%2C/', // , |
||
| 185 | '/%2F/', // / |
||
| 186 | '/%3A/', // : |
||
| 187 | '/%3B/', // ; |
||
| 188 | '/%3C/', // < |
||
| 189 | '/%3D/', // = |
||
| 190 | '/%3E/', // > |
||
| 191 | '/%3F/', // ? |
||
| 192 | '/%40/', // @ |
||
| 193 | '/%5B/', // [ |
||
| 194 | '/%5C/', // \ |
||
| 195 | '/%5D/', // ] |
||
| 196 | '/%5E/', // ^ |
||
| 197 | '/%7B/', // { |
||
| 198 | '/%7C/', // | |
||
| 199 | '/%7D/', // } |
||
| 200 | '/%7E/', // ~ |
||
| 201 | "/\./", // . |
||
| 202 | '/%2A/', |
||
| 203 | '/%2B/', |
||
| 204 | '/quot/', |
||
| 205 | ]; |
||
| 206 | $rep_pat = [ |
||
| 207 | '-', |
||
| 208 | '-', |
||
| 209 | '', |
||
| 210 | '', |
||
| 211 | '', |
||
| 212 | '-100', |
||
| 213 | '', |
||
| 214 | '-', |
||
| 215 | '', |
||
| 216 | '', |
||
| 217 | '', |
||
| 218 | '-', |
||
| 219 | '', |
||
| 220 | '', |
||
| 221 | '', |
||
| 222 | '-', |
||
| 223 | '', |
||
| 224 | '', |
||
| 225 | '-at-', |
||
| 226 | '', |
||
| 227 | '-', |
||
| 228 | '', |
||
| 229 | '-', |
||
| 230 | '', |
||
| 231 | '-', |
||
| 232 | '', |
||
| 233 | '-', |
||
| 234 | '', |
||
| 235 | '', |
||
| 236 | '+', |
||
| 237 | '', |
||
| 238 | ]; |
||
| 239 | $title = preg_replace($pattern, $rep_pat, $title); |
||
| 240 | |||
| 241 | // Transformation of characters with accents |
||
| 242 | // ° è é ê ë ç à â ä î ï ù ü û ô ö |
||
| 243 | $pattern = [ |
||
| 244 | '/%B0/', // ° |
||
| 245 | '/%E8/', // è |
||
| 246 | '/%E9/', // é |
||
| 247 | '/%EA/', // ê |
||
| 248 | '/%EB/', // ë |
||
| 249 | '/%E7/', // ç |
||
| 250 | '/%E0/', // à |
||
| 251 | '/%E2/', // â |
||
| 252 | '/%E4/', // ä |
||
| 253 | '/%EE/', // î |
||
| 254 | '/%EF/', // ï |
||
| 255 | '/%F9/', // ù |
||
| 256 | '/%FC/', // ü |
||
| 257 | '/%FB/', // û |
||
| 258 | '/%F4/', // ô |
||
| 259 | '/%F6/', // ö |
||
| 260 | '/%E3%A8/', |
||
| 261 | '/%E3%A9/', |
||
| 262 | '/%E3%A0/', |
||
| 263 | '/%E3%AA/', |
||
| 264 | '/%E3%A2/', |
||
| 265 | '/a%80%9C/', |
||
| 266 | '/a%80%9D/', |
||
| 267 | '/%E3%A7/', |
||
| 268 | ]; |
||
| 269 | $rep_pat = [ |
||
| 270 | '-', |
||
| 271 | 'e', |
||
| 272 | 'e', |
||
| 273 | 'e', |
||
| 274 | 'e', |
||
| 275 | 'c', |
||
| 276 | 'a', |
||
| 277 | 'a', |
||
| 278 | 'a', |
||
| 279 | 'i', |
||
| 280 | 'i', |
||
| 281 | 'u', |
||
| 282 | 'u', |
||
| 283 | 'u', |
||
| 284 | 'o', |
||
| 285 | 'o', |
||
| 286 | 'e', |
||
| 287 | 'e', |
||
| 288 | 'a', |
||
| 289 | 'e', |
||
| 290 | 'a', |
||
| 291 | '-', |
||
| 292 | '-', |
||
| 293 | 'c', |
||
| 294 | ]; |
||
| 295 | $title = preg_replace($pattern, $rep_pat, $title); |
||
| 296 | |||
| 297 | if (count($title) > 0) { |
||
| 298 | if ($withExt) { |
||
| 299 | $title .= '.html'; |
||
| 300 | } |
||
| 301 | |||
| 302 | return $title; |
||
| 303 | } |
||
| 304 | |||
| 305 | return ''; |
||
| 306 | } |
||
| 361 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.