| Conditions | 1 |
| Paths | 1 |
| Total Lines | 306 |
| Code Lines | 206 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 182 | public function dataInvalid() |
||
| 183 | { |
||
| 184 | return [ |
||
| 185 | 'empty notEmptyArray' => [ |
||
| 186 | (object) [ |
||
| 187 | 'value' => 'value', |
||
| 188 | 'defaultArray' => [], |
||
| 189 | 'optionalArray' => [], |
||
| 190 | 'requiredArray' => [], |
||
| 191 | 'notEmptyArray' => [], |
||
| 192 | ], |
||
| 193 | [ |
||
| 194 | (object) [ |
||
| 195 | 'message' => 'There must be a minimum of 1 items in the array', |
||
| 196 | 'propertyPath' => 'notEmptyArray', |
||
| 197 | ], |
||
| 198 | ], |
||
| 199 | ], |
||
| 200 | 'no requiredArray' => [ |
||
| 201 | (object) [ |
||
| 202 | 'value' => 'value', |
||
| 203 | 'defaultArray' => [], |
||
| 204 | 'optionalArray' => [], |
||
| 205 | ], |
||
| 206 | [ |
||
| 207 | (object) [ |
||
| 208 | 'message' => 'The property requiredArray is required', |
||
| 209 | 'propertyPath' => 'requiredArray', |
||
| 210 | ], |
||
| 211 | ], |
||
| 212 | ], |
||
| 213 | 'no defaultArray' => [ |
||
| 214 | (object) [ |
||
| 215 | 'value' => 'value', |
||
| 216 | 'optionalArray' => [], |
||
| 217 | 'requiredArray' => [], |
||
| 218 | ], |
||
| 219 | [ |
||
| 220 | (object) [ |
||
| 221 | 'message' => 'The property defaultArray is required', |
||
| 222 | 'propertyPath' => 'defaultArray', |
||
| 223 | ], |
||
| 224 | ], |
||
| 225 | ], |
||
| 226 | 'no value' => [ |
||
| 227 | (object) [ |
||
| 228 | 'defaultArray' => [ |
||
| 229 | (object) [ |
||
| 230 | 'subDefaultHash' => (object) ['value' => 'defaultHash.subDefaultHash.value'], |
||
| 231 | 'subOptionalHash' => (object) ['value' => 'defaultHash.subOptionalHash.value'], |
||
| 232 | 'subRequiredHash' => (object) ['value' => 'defaultHash.subRequiredHash.value'], |
||
| 233 | ], |
||
| 234 | ], |
||
| 235 | 'optionalArray' => [ |
||
| 236 | (object) [ |
||
| 237 | 'subDefaultHash' => (object) ['value' => 'optionalHash.subDefaultHash.value'], |
||
| 238 | 'subOptionalHash' => (object) ['value' => 'optionalHash.subOptionalHash.value'], |
||
| 239 | 'subRequiredHash' => (object) ['value' => 'optionalHash.subRequiredHash.value'], |
||
| 240 | ], |
||
| 241 | ], |
||
| 242 | 'requiredArray' => [ |
||
| 243 | (object) [ |
||
| 244 | 'subDefaultHash' => (object) ['value' => 'requiredHash.subDefaultHash.value'], |
||
| 245 | 'subOptionalHash' => (object) ['value' => 'requiredHash.subOptionalHash.value'], |
||
| 246 | 'subRequiredHash' => (object) ['value' => 'requiredHash.subRequiredHash.value'], |
||
| 247 | ], |
||
| 248 | ], |
||
| 249 | 'notEmptyArray' => [ |
||
| 250 | (object) [ |
||
| 251 | 'subDefaultHash' => (object) ['value' => 'notEmptyArray.subDefaultHash.value'], |
||
| 252 | 'subOptionalHash' => (object) ['value' => 'notEmptyArray.subOptionalHash.value'], |
||
| 253 | 'subRequiredHash' => (object) ['value' => 'notEmptyArray.subRequiredHash.value'], |
||
| 254 | ], |
||
| 255 | ], |
||
| 256 | ], |
||
| 257 | [ |
||
| 258 | (object) [ |
||
| 259 | 'message' => 'The property value is required', |
||
| 260 | 'propertyPath' => 'value', |
||
| 261 | ], |
||
| 262 | (object) [ |
||
| 263 | 'message' => 'The property value is required', |
||
| 264 | 'propertyPath' => 'defaultArray[0].value', |
||
| 265 | ], |
||
| 266 | (object) [ |
||
| 267 | 'message' => 'The property value is required', |
||
| 268 | 'propertyPath' => 'optionalArray[0].value', |
||
| 269 | ], |
||
| 270 | (object) [ |
||
| 271 | 'message' => 'The property value is required', |
||
| 272 | 'propertyPath' => 'requiredArray[0].value', |
||
| 273 | ], |
||
| 274 | (object) [ |
||
| 275 | 'message' => 'The property value is required', |
||
| 276 | 'propertyPath' => 'notEmptyArray[0].value', |
||
| 277 | ], |
||
| 278 | ], |
||
| 279 | ], |
||
| 280 | 'no value at all' => [ |
||
| 281 | (object) [ |
||
| 282 | 'defaultArray' => [ |
||
| 283 | (object) [ |
||
| 284 | 'subDefaultHash' => (object) [], |
||
| 285 | 'subOptionalHash' => (object) [], |
||
| 286 | 'subRequiredHash' => (object) [], |
||
| 287 | ], |
||
| 288 | ], |
||
| 289 | 'optionalArray' => [ |
||
| 290 | (object) [ |
||
| 291 | 'subDefaultHash' => (object) [], |
||
| 292 | 'subOptionalHash' => (object) [], |
||
| 293 | 'subRequiredHash' => (object) [], |
||
| 294 | ], |
||
| 295 | ], |
||
| 296 | 'requiredArray' => [ |
||
| 297 | (object) [ |
||
| 298 | 'subDefaultHash' => (object) [], |
||
| 299 | 'subOptionalHash' => (object) [], |
||
| 300 | 'subRequiredHash' => (object) [], |
||
| 301 | ], |
||
| 302 | ], |
||
| 303 | 'notEmptyArray' => [ |
||
| 304 | (object) [ |
||
| 305 | 'subDefaultHash' => (object) [], |
||
| 306 | 'subOptionalHash' => (object) [], |
||
| 307 | 'subRequiredHash' => (object) [], |
||
| 308 | ], |
||
| 309 | ], |
||
| 310 | ], |
||
| 311 | [ |
||
| 312 | (object) [ |
||
| 313 | 'message' => 'The property value is required', |
||
| 314 | 'propertyPath' => 'value', |
||
| 315 | ], |
||
| 316 | |||
| 317 | (object) [ |
||
| 318 | 'message' => 'The property value is required', |
||
| 319 | 'propertyPath' => 'defaultArray[0].value', |
||
| 320 | ], |
||
| 321 | (object) [ |
||
| 322 | 'message' => 'The property value is required', |
||
| 323 | 'propertyPath' => 'defaultArray[0].subDefaultHash.value', |
||
| 324 | ], |
||
| 325 | (object) [ |
||
| 326 | 'message' => 'The property value is required', |
||
| 327 | 'propertyPath' => 'defaultArray[0].subOptionalHash.value', |
||
| 328 | ], |
||
| 329 | (object) [ |
||
| 330 | 'message' => 'The property value is required', |
||
| 331 | 'propertyPath' => 'defaultArray[0].subRequiredHash.value', |
||
| 332 | ], |
||
| 333 | |||
| 334 | (object) [ |
||
| 335 | 'message' => 'The property value is required', |
||
| 336 | 'propertyPath' => 'optionalArray[0].value', |
||
| 337 | ], |
||
| 338 | (object) [ |
||
| 339 | 'message' => 'The property value is required', |
||
| 340 | 'propertyPath' => 'optionalArray[0].subDefaultHash.value', |
||
| 341 | ], |
||
| 342 | (object) [ |
||
| 343 | 'message' => 'The property value is required', |
||
| 344 | 'propertyPath' => 'optionalArray[0].subOptionalHash.value', |
||
| 345 | ], |
||
| 346 | (object) [ |
||
| 347 | 'message' => 'The property value is required', |
||
| 348 | 'propertyPath' => 'optionalArray[0].subRequiredHash.value', |
||
| 349 | ], |
||
| 350 | |||
| 351 | (object) [ |
||
| 352 | 'message' => 'The property value is required', |
||
| 353 | 'propertyPath' => 'requiredArray[0].value', |
||
| 354 | ], |
||
| 355 | (object) [ |
||
| 356 | 'message' => 'The property value is required', |
||
| 357 | 'propertyPath' => 'requiredArray[0].subDefaultHash.value', |
||
| 358 | ], |
||
| 359 | (object) [ |
||
| 360 | 'message' => 'The property value is required', |
||
| 361 | 'propertyPath' => 'requiredArray[0].subOptionalHash.value', |
||
| 362 | ], |
||
| 363 | (object) [ |
||
| 364 | 'message' => 'The property value is required', |
||
| 365 | 'propertyPath' => 'requiredArray[0].subRequiredHash.value', |
||
| 366 | ], |
||
| 367 | |||
| 368 | (object) [ |
||
| 369 | 'message' => 'The property value is required', |
||
| 370 | 'propertyPath' => 'notEmptyArray[0].value', |
||
| 371 | ], |
||
| 372 | (object) [ |
||
| 373 | 'message' => 'The property value is required', |
||
| 374 | 'propertyPath' => 'notEmptyArray[0].subDefaultHash.value', |
||
| 375 | ], |
||
| 376 | (object) [ |
||
| 377 | 'message' => 'The property value is required', |
||
| 378 | 'propertyPath' => 'notEmptyArray[0].subOptionalHash.value', |
||
| 379 | ], |
||
| 380 | (object) [ |
||
| 381 | 'message' => 'The property value is required', |
||
| 382 | 'propertyPath' => 'notEmptyArray[0].subRequiredHash.value', |
||
| 383 | ], |
||
| 384 | ], |
||
| 385 | ], |
||
| 386 | 'no requiredHash' => [ |
||
| 387 | (object) [ |
||
| 388 | 'value' => 'value', |
||
| 389 | 'defaultArray' => [ |
||
| 390 | (object) [ |
||
| 391 | 'value' => 'defaultArray.value', |
||
| 392 | 'subDefaultHash' => (object) ['value' => 'defaultArray.subDefaultHash.value'], |
||
| 393 | 'subOptionalHash' => (object) ['value' => 'defaultArray.subOptionalHash.value'], |
||
| 394 | ], |
||
| 395 | ], |
||
| 396 | 'optionalArray' => [ |
||
| 397 | (object) [ |
||
| 398 | 'value' => 'defaultArray.value', |
||
| 399 | 'subDefaultHash' => (object) ['value' => 'optionalArray.subDefaultHash.value'], |
||
| 400 | 'subOptionalHash' => (object) ['value' => 'optionalArray.subOptionalHash.value'], |
||
| 401 | ], |
||
| 402 | ], |
||
| 403 | 'requiredArray' => [ |
||
| 404 | (object) [ |
||
| 405 | 'value' => 'defaultArray.value', |
||
| 406 | 'subDefaultHash' => (object) ['value' => 'requiredArray.subDefaultHash.value'], |
||
| 407 | 'subOptionalHash' => (object) ['value' => 'requiredArray.subOptionalHash.value'], |
||
| 408 | ], |
||
| 409 | ], |
||
| 410 | 'notEmptyArray' => [ |
||
| 411 | (object) [ |
||
| 412 | 'value' => 'notEmptyArray.value', |
||
| 413 | 'subDefaultHash' => (object) ['value' => 'notEmptyArray.subDefaultHash.value'], |
||
| 414 | ], |
||
| 415 | ], |
||
| 416 | ], |
||
| 417 | [ |
||
| 418 | (object) [ |
||
| 419 | 'message' => 'The property subRequiredHash is required', |
||
| 420 | 'propertyPath' => 'defaultArray[0].subRequiredHash', |
||
| 421 | ], |
||
| 422 | (object) [ |
||
| 423 | 'message' => 'The property subRequiredHash is required', |
||
| 424 | 'propertyPath' => 'optionalArray[0].subRequiredHash', |
||
| 425 | ], |
||
| 426 | (object) [ |
||
| 427 | 'message' => 'The property subRequiredHash is required', |
||
| 428 | 'propertyPath' => 'requiredArray[0].subRequiredHash', |
||
| 429 | ], |
||
| 430 | (object) [ |
||
| 431 | 'message' => 'The property subRequiredHash is required', |
||
| 432 | 'propertyPath' => 'notEmptyArray[0].subRequiredHash', |
||
| 433 | ], |
||
| 434 | ], |
||
| 435 | ], |
||
| 436 | 'no defaultHash' => [ |
||
| 437 | (object) [ |
||
| 438 | 'value' => 'value', |
||
| 439 | 'defaultArray' => [ |
||
| 440 | (object) [ |
||
| 441 | 'value' => 'defaultArray.value', |
||
| 442 | 'subOptionalHash' => (object) ['value' => 'defaultArray.subOptionalHash.value'], |
||
| 443 | 'subRequiredHash' => (object) ['value' => 'defaultArray.subRequiredHash.value'], |
||
| 444 | ], |
||
| 445 | ], |
||
| 446 | 'optionalArray' => [ |
||
| 447 | (object) [ |
||
| 448 | 'value' => 'defaultArray.value', |
||
| 449 | 'subOptionalHash' => (object) ['value' => 'optionalArray.subOptionalHash.value'], |
||
| 450 | 'subRequiredHash' => (object) ['value' => 'optionalArray.subRequiredHash.value'], |
||
| 451 | ], |
||
| 452 | ], |
||
| 453 | 'requiredArray' => [ |
||
| 454 | (object) [ |
||
| 455 | 'value' => 'defaultArray.value', |
||
| 456 | 'subOptionalHash' => (object) ['value' => 'requiredArray.subOptionalHash.value'], |
||
| 457 | 'subRequiredHash' => (object) ['value' => 'requiredArray.subRequiredHash.value'], |
||
| 458 | ], |
||
| 459 | ], |
||
| 460 | 'notEmptyArray' => [ |
||
| 461 | (object) [ |
||
| 462 | 'value' => 'notEmptyArray.value', |
||
| 463 | 'subRequiredHash' => (object) ['value' => 'notEmptyArray.subRequiredHash.value'], |
||
| 464 | ], |
||
| 465 | ], |
||
| 466 | ], |
||
| 467 | [ |
||
| 468 | (object) [ |
||
| 469 | 'message' => 'The property subDefaultHash is required', |
||
| 470 | 'propertyPath' => 'defaultArray[0].subDefaultHash', |
||
| 471 | ], |
||
| 472 | (object) [ |
||
| 473 | 'message' => 'The property subDefaultHash is required', |
||
| 474 | 'propertyPath' => 'optionalArray[0].subDefaultHash', |
||
| 475 | ], |
||
| 476 | (object) [ |
||
| 477 | 'message' => 'The property subDefaultHash is required', |
||
| 478 | 'propertyPath' => 'requiredArray[0].subDefaultHash', |
||
| 479 | ], |
||
| 480 | (object) [ |
||
| 481 | 'message' => 'The property subDefaultHash is required', |
||
| 482 | 'propertyPath' => 'notEmptyArray[0].subDefaultHash', |
||
| 483 | ], |
||
| 484 | ], |
||
| 485 | ], |
||
| 486 | ]; |
||
| 487 | } |
||
| 488 | } |
||
| 489 |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.