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