| Conditions | 3 |
| Paths | 2 |
| Total Lines | 179 |
| Code Lines | 122 |
| 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 |
||
| 201 | public function getCalleeInfoProvider() |
||
| 202 | { |
||
| 203 | $basetrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
||
| 204 | $dumpframe = array( |
||
| 205 | 'class' => 'Kint', |
||
| 206 | 'function' => 'dump', |
||
| 207 | ); |
||
| 208 | |||
| 209 | $data['empty trace'] = array( |
||
| 210 | 'trace' => array( |
||
| 211 | ), |
||
| 212 | 'param_count' => 1234, |
||
| 213 | 'expect' => array( |
||
| 214 | null, |
||
| 215 | array(), |
||
| 216 | null, |
||
| 217 | null, |
||
| 218 | array(), |
||
| 219 | ), |
||
| 220 | ); |
||
| 221 | |||
| 222 | $data['full trace'] = array( |
||
| 223 | 'trace' => array_merge(array($dumpframe), $basetrace), |
||
| 224 | 'param_count' => 1234, |
||
| 225 | 'expect' => array( |
||
| 226 | null, |
||
| 227 | array(), |
||
| 228 | $dumpframe, |
||
| 229 | array( |
||
| 230 | 'function' => __FUNCTION__, |
||
| 231 | 'class' => __CLASS__, |
||
| 232 | 'type' => '->', |
||
| 233 | ), |
||
| 234 | ), |
||
| 235 | ); |
||
| 236 | |||
| 237 | $data['trace with params'] = array( |
||
| 238 | 'trace' => array_merge( |
||
| 239 | array( |
||
| 240 | $dumpframe + array( |
||
| 241 | 'file' => TestClass::DUMP_FILE, |
||
| 242 | 'line' => TestClass::DUMP_LINE, |
||
| 243 | ), |
||
| 244 | ), |
||
| 245 | $basetrace |
||
| 246 | ), |
||
| 247 | 'param_count' => 3, |
||
| 248 | 'expect' => array( |
||
| 249 | array( |
||
| 250 | array('name' => '$x', 'path' => '$x', 'expression' => false), |
||
| 251 | array('name' => '$y', 'path' => '$y', 'expression' => false), |
||
| 252 | array('name' => '$z', 'path' => '$z', 'expression' => false), |
||
| 253 | ), |
||
| 254 | array(), |
||
| 255 | $dumpframe + array( |
||
| 256 | 'file' => TestClass::DUMP_FILE, |
||
| 257 | 'line' => TestClass::DUMP_LINE, |
||
| 258 | ), |
||
| 259 | ), |
||
| 260 | ); |
||
| 261 | |||
| 262 | $data['trace with modifiers'] = array( |
||
| 263 | 'trace' => array_merge( |
||
| 264 | array( |
||
| 265 | $dumpframe + array( |
||
| 266 | 'file' => TestClass::DUMP_FILE, |
||
| 267 | 'line' => TestClass::DUMP_LINE + 1, |
||
| 268 | ), |
||
| 269 | ), |
||
| 270 | $basetrace |
||
| 271 | ), |
||
| 272 | 'param_count' => 0, |
||
| 273 | 'expect' => array( |
||
| 274 | array(), |
||
| 275 | array('!', '+'), |
||
| 276 | $dumpframe + array( |
||
| 277 | 'file' => TestClass::DUMP_FILE, |
||
| 278 | 'line' => TestClass::DUMP_LINE + 1, |
||
| 279 | ), |
||
| 280 | ), |
||
| 281 | ); |
||
| 282 | |||
| 283 | $data['trace function with modifier'] = array( |
||
| 284 | 'trace' => array_merge( |
||
| 285 | array( |
||
| 286 | array( |
||
| 287 | 'function' => 'd', |
||
| 288 | 'file' => TestClass::DUMP_FILE, |
||
| 289 | 'line' => TestClass::DUMP_LINE + 2, |
||
| 290 | ), |
||
| 291 | ), |
||
| 292 | $basetrace |
||
| 293 | ), |
||
| 294 | 'param_count' => 1, |
||
| 295 | 'expect' => array( |
||
| 296 | array( |
||
| 297 | array( |
||
| 298 | 'name' => '$x', |
||
| 299 | 'path' => '$x', |
||
| 300 | 'expression' => false, |
||
| 301 | ), |
||
| 302 | ), |
||
| 303 | array('~'), |
||
| 304 | array( |
||
| 305 | 'function' => 'd', |
||
| 306 | 'file' => TestClass::DUMP_FILE, |
||
| 307 | 'line' => TestClass::DUMP_LINE + 2, |
||
| 308 | ), |
||
| 309 | ), |
||
| 310 | ); |
||
| 311 | |||
| 312 | // HHVM doesn't support multiple unpack parameters |
||
| 313 | if (KINT_PHP56 && !defined('HHVM_VERSION')) { |
||
| 314 | $data['trace with unpack'] = array( |
||
| 315 | 'trace' => array_merge( |
||
| 316 | array( |
||
| 317 | $dumpframe + array( |
||
| 318 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 319 | 'line' => Php56TestClass::DUMP_LINE, |
||
| 320 | ), |
||
| 321 | ), |
||
| 322 | $basetrace |
||
| 323 | ), |
||
| 324 | 'param_count' => 4, |
||
| 325 | 'expect' => array( |
||
| 326 | array( |
||
| 327 | array( |
||
| 328 | 'name' => '$x', |
||
| 329 | 'path' => '$x', |
||
| 330 | 'expression' => false, |
||
| 331 | ), |
||
| 332 | array( |
||
| 333 | 'name' => '$y', |
||
| 334 | 'path' => '$y', |
||
| 335 | 'expression' => false, |
||
| 336 | ), |
||
| 337 | array( |
||
| 338 | 'name' => 'reset($z)', |
||
| 339 | 'path' => 'reset($z)', |
||
| 340 | 'expression' => false, |
||
| 341 | ), |
||
| 342 | array( |
||
| 343 | 'name' => 'array_values($z)[1]', |
||
| 344 | 'path' => 'array_values($z)[1]', |
||
| 345 | 'expression' => false, |
||
| 346 | ), |
||
| 347 | ), |
||
| 348 | array(), |
||
| 349 | $dumpframe + array( |
||
| 350 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 351 | 'line' => Php56TestClass::DUMP_LINE, |
||
| 352 | ), |
||
| 353 | ), |
||
| 354 | ); |
||
| 355 | |||
| 356 | $data['trace with double unpack'] = array( |
||
| 357 | 'trace' => array_merge( |
||
| 358 | array( |
||
| 359 | $dumpframe + array( |
||
| 360 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 361 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
| 362 | ), |
||
| 363 | ), |
||
| 364 | $basetrace |
||
| 365 | ), |
||
| 366 | 'param_count' => 10, |
||
| 367 | 'expect' => array( |
||
| 368 | array(), |
||
| 369 | array(), |
||
| 370 | $dumpframe + array( |
||
| 371 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 372 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
| 373 | ), |
||
| 374 | ), |
||
| 375 | ); |
||
| 376 | } |
||
| 377 | |||
| 378 | return $data; |
||
| 379 | } |
||
| 380 | |||
| 397 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString.