| 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 |
||
| 181 | public function getCalleeInfoProvider() |
||
| 182 | { |
||
| 183 | $basetrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); |
||
| 184 | $dumpframe = array( |
||
| 185 | 'class' => 'Kint', |
||
| 186 | 'function' => 'dump', |
||
| 187 | ); |
||
| 188 | |||
| 189 | $data['empty trace'] = array( |
||
| 190 | 'trace' => array( |
||
| 191 | ), |
||
| 192 | 'param_count' => 1234, |
||
| 193 | 'expect' => array( |
||
| 194 | null, |
||
| 195 | array(), |
||
| 196 | null, |
||
| 197 | null, |
||
| 198 | array(), |
||
| 199 | ), |
||
| 200 | ); |
||
| 201 | |||
| 202 | $data['full trace'] = array( |
||
| 203 | 'trace' => array_merge(array($dumpframe), $basetrace), |
||
| 204 | 'param_count' => 1234, |
||
| 205 | 'expect' => array( |
||
| 206 | null, |
||
| 207 | array(), |
||
| 208 | $dumpframe, |
||
| 209 | array( |
||
| 210 | 'function' => __FUNCTION__, |
||
| 211 | 'class' => __CLASS__, |
||
| 212 | 'type' => '->', |
||
| 213 | ), |
||
| 214 | ), |
||
| 215 | ); |
||
| 216 | |||
| 217 | $data['trace with params'] = array( |
||
| 218 | 'trace' => array_merge( |
||
| 219 | array( |
||
| 220 | $dumpframe + array( |
||
| 221 | 'file' => TestClass::DUMP_FILE, |
||
| 222 | 'line' => TestClass::DUMP_LINE, |
||
| 223 | ), |
||
| 224 | ), |
||
| 225 | $basetrace |
||
| 226 | ), |
||
| 227 | 'param_count' => 3, |
||
| 228 | 'expect' => array( |
||
| 229 | array( |
||
| 230 | array('name' => '$x', 'path' => '$x', 'expression' => false), |
||
| 231 | array('name' => '$y', 'path' => '$y', 'expression' => false), |
||
| 232 | array('name' => '$z', 'path' => '$z', 'expression' => false), |
||
| 233 | ), |
||
| 234 | array(), |
||
| 235 | $dumpframe + array( |
||
| 236 | 'file' => TestClass::DUMP_FILE, |
||
| 237 | 'line' => TestClass::DUMP_LINE, |
||
| 238 | ), |
||
| 239 | ), |
||
| 240 | ); |
||
| 241 | |||
| 242 | $data['trace with modifiers'] = array( |
||
| 243 | 'trace' => array_merge( |
||
| 244 | array( |
||
| 245 | $dumpframe + array( |
||
| 246 | 'file' => TestClass::DUMP_FILE, |
||
| 247 | 'line' => TestClass::DUMP_LINE + 1, |
||
| 248 | ), |
||
| 249 | ), |
||
| 250 | $basetrace |
||
| 251 | ), |
||
| 252 | 'param_count' => 0, |
||
| 253 | 'expect' => array( |
||
| 254 | array(), |
||
| 255 | array('!', '+'), |
||
| 256 | $dumpframe + array( |
||
| 257 | 'file' => TestClass::DUMP_FILE, |
||
| 258 | 'line' => TestClass::DUMP_LINE + 1, |
||
| 259 | ), |
||
| 260 | ), |
||
| 261 | ); |
||
| 262 | |||
| 263 | $data['trace function with modifier'] = array( |
||
| 264 | 'trace' => array_merge( |
||
| 265 | array( |
||
| 266 | array( |
||
| 267 | 'function' => 'd', |
||
| 268 | 'file' => TestClass::DUMP_FILE, |
||
| 269 | 'line' => TestClass::DUMP_LINE + 2, |
||
| 270 | ), |
||
| 271 | ), |
||
| 272 | $basetrace |
||
| 273 | ), |
||
| 274 | 'param_count' => 1, |
||
| 275 | 'expect' => array( |
||
| 276 | array( |
||
| 277 | array( |
||
| 278 | 'name' => '$x', |
||
| 279 | 'path' => '$x', |
||
| 280 | 'expression' => false, |
||
| 281 | ), |
||
| 282 | ), |
||
| 283 | array('~'), |
||
| 284 | array( |
||
| 285 | 'function' => 'd', |
||
| 286 | 'file' => TestClass::DUMP_FILE, |
||
| 287 | 'line' => TestClass::DUMP_LINE + 2, |
||
| 288 | ), |
||
| 289 | ), |
||
| 290 | ); |
||
| 291 | |||
| 292 | // HHVM doesn't support multiple unpack parameters |
||
| 293 | if (KINT_PHP56 && !defined('HHVM_VERSION')) { |
||
| 294 | $data['trace with unpack'] = array( |
||
| 295 | 'trace' => array_merge( |
||
| 296 | array( |
||
| 297 | $dumpframe + array( |
||
| 298 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 299 | 'line' => Php56TestClass::DUMP_LINE, |
||
| 300 | ), |
||
| 301 | ), |
||
| 302 | $basetrace |
||
| 303 | ), |
||
| 304 | 'param_count' => 4, |
||
| 305 | 'expect' => array( |
||
| 306 | array( |
||
| 307 | array( |
||
| 308 | 'name' => '$x', |
||
| 309 | 'path' => '$x', |
||
| 310 | 'expression' => false, |
||
| 311 | ), |
||
| 312 | array( |
||
| 313 | 'name' => '$y', |
||
| 314 | 'path' => '$y', |
||
| 315 | 'expression' => false, |
||
| 316 | ), |
||
| 317 | array( |
||
| 318 | 'name' => 'reset($z)', |
||
| 319 | 'path' => 'reset($z)', |
||
| 320 | 'expression' => false, |
||
| 321 | ), |
||
| 322 | array( |
||
| 323 | 'name' => 'array_values($z)[1]', |
||
| 324 | 'path' => 'array_values($z)[1]', |
||
| 325 | 'expression' => false, |
||
| 326 | ), |
||
| 327 | ), |
||
| 328 | array(), |
||
| 329 | $dumpframe + array( |
||
| 330 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 331 | 'line' => Php56TestClass::DUMP_LINE, |
||
| 332 | ), |
||
| 333 | ), |
||
| 334 | ); |
||
| 335 | |||
| 336 | $data['trace with double unpack'] = array( |
||
| 337 | 'trace' => array_merge( |
||
| 338 | array( |
||
| 339 | $dumpframe + array( |
||
| 340 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 341 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
| 342 | ), |
||
| 343 | ), |
||
| 344 | $basetrace |
||
| 345 | ), |
||
| 346 | 'param_count' => 10, |
||
| 347 | 'expect' => array( |
||
| 348 | array(), |
||
| 349 | array(), |
||
| 350 | $dumpframe + array( |
||
| 351 | 'file' => Php56TestClass::DUMP_FILE, |
||
| 352 | 'line' => Php56TestClass::DUMP_LINE + 1, |
||
| 353 | ), |
||
| 354 | ), |
||
| 355 | ); |
||
| 356 | } |
||
| 357 | |||
| 358 | return $data; |
||
| 359 | } |
||
| 360 | |||
| 377 |
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.