| Conditions | 1 |
| Paths | 1 |
| Total Lines | 258 |
| Code Lines | 210 |
| 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 declare(strict_types=1); |
||
| 257 | function BuildDefaultSet () { |
||
| 258 | $defaultSet = []; |
||
| 259 | $defaultSet[] = [ |
||
| 260 | 'type' => Constants::FIELD_LABEL, |
||
| 261 | 'caption' => \_MA_WGEVENTS_FIELD_LABEL, |
||
| 262 | 'desc' => '', |
||
| 263 | 'values' => '', |
||
| 264 | 'placeholder' => '', |
||
| 265 | 'required' => 0, |
||
| 266 | 'default' => 0, |
||
| 267 | 'print' => 1, |
||
| 268 | 'display_desc' => 1, |
||
| 269 | 'display_values' => 0, |
||
| 270 | 'display_placeholder' => 0, |
||
| 271 | 'custom' => 0, |
||
| 272 | ]; |
||
| 273 | $defaultSet[] = [ |
||
| 274 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 275 | 'caption' => \_MA_WGEVENTS_FIELD_TEXTBOX, |
||
| 276 | 'desc' => '', |
||
| 277 | 'values' => '', |
||
| 278 | 'placeholder' => '', |
||
| 279 | 'required' => 0, |
||
| 280 | 'default' => 0, |
||
| 281 | 'print' => 1, |
||
| 282 | 'display_desc' => 1, |
||
| 283 | 'display_values' => 0, |
||
| 284 | 'display_placeholder' => 1, |
||
| 285 | 'custom' => 0, |
||
| 286 | ]; |
||
| 287 | $defaultSet[] = [ |
||
| 288 | 'type' => Constants::FIELD_TEXTAREA, |
||
| 289 | 'caption' => \_MA_WGEVENTS_FIELD_TEXTAREA, |
||
| 290 | 'desc' => '', |
||
| 291 | 'values' => '', |
||
| 292 | 'placeholder' => '', |
||
| 293 | 'required' => 0, |
||
| 294 | 'default' => 0, |
||
| 295 | 'print' => 1, |
||
| 296 | 'display_desc' => 1, |
||
| 297 | 'display_values' => 0, |
||
| 298 | 'display_placeholder' => 1, |
||
| 299 | 'custom' => 0, |
||
| 300 | ]; |
||
| 301 | /* |
||
| 302 | $defaultSet[] = [ |
||
| 303 | 'type' => Constants::FIELD_TEXTEDITOR, |
||
| 304 | 'caption' => \_MA_WGEVENTS_FIELD_TEXTEDITOR, |
||
| 305 | 'desc' => '', |
||
| 306 | 'values' => '', |
||
| 307 | 'placeholder' => '', |
||
| 308 | 'required' => 0, |
||
| 309 | 'default' => 0, |
||
| 310 | 'print' => 1, |
||
| 311 | 'display_desc' => 1, |
||
| 312 | 'display_values' => 0, |
||
| 313 | 'display_placeholder' => 1, |
||
| 314 | 'custom' => 0, |
||
| 315 | ]; |
||
| 316 | */ |
||
| 317 | $defaultSet[] = [ |
||
| 318 | 'type' => Constants::FIELD_SELECTBOX, |
||
| 319 | 'caption' => \_MA_WGEVENTS_FIELD_SELECTBOX, |
||
| 320 | 'desc' => '', |
||
| 321 | 'values' => '', |
||
| 322 | 'placeholder' => '', |
||
| 323 | 'required' => 0, |
||
| 324 | 'default' => 0, |
||
| 325 | 'print' => 1, |
||
| 326 | 'display_desc' => 1, |
||
| 327 | 'display_values' => 1, |
||
| 328 | 'display_placeholder' => 0, |
||
| 329 | 'custom' => 0, |
||
| 330 | ]; |
||
| 331 | $defaultSet[] = [ |
||
| 332 | 'type' => Constants::FIELD_COMBOBOX, |
||
| 333 | 'caption' => \_MA_WGEVENTS_FIELD_COMBOBOX, |
||
| 334 | 'desc' => '', |
||
| 335 | 'values' => '', |
||
| 336 | 'placeholder' => '', |
||
| 337 | 'required' => 0, |
||
| 338 | 'default' => 0, |
||
| 339 | 'print' => 1, |
||
| 340 | 'display_desc' => 1, |
||
| 341 | 'display_values' => 1, |
||
| 342 | 'display_placeholder' => 0, |
||
| 343 | 'custom' => 0, |
||
| 344 | ]; |
||
| 345 | $defaultSet[] = [ |
||
| 346 | 'type' => Constants::FIELD_CHECKBOX, |
||
| 347 | 'caption' => \_MA_WGEVENTS_FIELD_CHECKBOX, |
||
| 348 | 'desc' => '', |
||
| 349 | 'values' => '', |
||
| 350 | 'placeholder' => '', |
||
| 351 | 'required' => 0, |
||
| 352 | 'default' => 0, |
||
| 353 | 'print' => 1, |
||
| 354 | 'display_desc' => 1, |
||
| 355 | 'display_values' => 1, |
||
| 356 | 'display_placeholder' => 0, |
||
| 357 | 'custom' => 0, |
||
| 358 | ]; |
||
| 359 | $defaultSet[] = [ |
||
| 360 | 'type' => Constants::FIELD_RADIO, |
||
| 361 | 'caption' => \_MA_WGEVENTS_FIELD_RADIO, |
||
| 362 | 'desc' => '', |
||
| 363 | 'values' => '', |
||
| 364 | 'placeholder' => '', |
||
| 365 | 'required' => 0, |
||
| 366 | 'default' => 0, |
||
| 367 | 'print' => 1, |
||
| 368 | 'display_desc' => 1, |
||
| 369 | 'display_values' => 1, |
||
| 370 | 'display_placeholder' => 0, |
||
| 371 | 'custom' => 0, |
||
| 372 | ]; |
||
| 373 | $defaultSet[] = [ |
||
| 374 | 'type' => Constants::FIELD_RADIOYN, |
||
| 375 | 'caption' => \_MA_WGEVENTS_FIELD_RADIOYN, |
||
| 376 | 'desc' => '', |
||
| 377 | 'values' => '', |
||
| 378 | 'placeholder' => '', |
||
| 379 | 'required' => 0, |
||
| 380 | 'default' => 0, |
||
| 381 | 'print' => 1, |
||
| 382 | 'display_desc' => 1, |
||
| 383 | 'display_values' => 0, |
||
| 384 | 'display_placeholder' => 0, |
||
| 385 | 'custom' => 0, |
||
| 386 | ]; |
||
| 387 | $defaultSet[] = [ |
||
| 388 | 'type' => Constants::FIELD_DATE, |
||
| 389 | 'caption' => \_MA_WGEVENTS_FIELD_DATE, |
||
| 390 | 'desc' => '', |
||
| 391 | 'values' => '', |
||
| 392 | 'placeholder' => '', |
||
| 393 | 'required' => 0, |
||
| 394 | 'default' => 0, |
||
| 395 | 'print' => 1, |
||
| 396 | 'display_desc' => 1, |
||
| 397 | 'display_values' => 0, |
||
| 398 | 'display_placeholder' => 0, |
||
| 399 | 'custom' => 0, |
||
| 400 | ]; |
||
| 401 | /* |
||
| 402 | $defaultSet[] = [ |
||
| 403 | 'type' => Constants::FIELD_DATETIME, |
||
| 404 | 'caption' => \_MA_WGEVENTS_FIELD_DATETIME, |
||
| 405 | 'desc' => '', |
||
| 406 | 'values' => '', |
||
| 407 | 'required' => 0, |
||
| 408 | 'default' => 0, |
||
| 409 | 'print' => 1, |
||
| 410 | 'display_values' => 0, |
||
| 411 | 'display_placeholder' => 0, |
||
| 412 | 'custom' => 0, |
||
| 413 | ]; |
||
| 414 | */ |
||
| 415 | $defaultSet[] = [ |
||
| 416 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 417 | 'caption' => \_AM_WGEVENTS_FIELD_PHONE, |
||
| 418 | 'desc' => '', |
||
| 419 | 'values' => '', |
||
| 420 | 'placeholder' => \_AM_WGEVENTS_FIELD_PHONE_VALUE, |
||
| 421 | 'required' => 0, |
||
| 422 | 'default' => 1, |
||
| 423 | 'print' => 1, |
||
| 424 | 'display_desc' => 1, |
||
| 425 | 'display_values' => 0, |
||
| 426 | 'display_placeholder' => 1, |
||
| 427 | 'custom' => 1, |
||
| 428 | ]; |
||
| 429 | $defaultSet[] = [ |
||
| 430 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 431 | 'caption' => \_AM_WGEVENTS_FIELD_ADDRESS, |
||
| 432 | 'desc' => '', |
||
| 433 | 'values' => '', |
||
| 434 | 'placeholder' => \_AM_WGEVENTS_FIELD_ADDRESS_VALUE, |
||
| 435 | 'required' => 0, |
||
| 436 | 'default' => 0, |
||
| 437 | 'print' => 1, |
||
| 438 | 'display_desc' => 1, |
||
| 439 | 'display_values' => 0, |
||
| 440 | 'display_placeholder' => 1, |
||
| 441 | 'custom' => 1, |
||
| 442 | ]; |
||
| 443 | $defaultSet[] = [ |
||
| 444 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 445 | 'caption' => \_AM_WGEVENTS_FIELD_POSTAL, |
||
| 446 | 'desc' => '', |
||
| 447 | 'values' => '', |
||
| 448 | 'placeholder' => \_AM_WGEVENTS_FIELD_POSTAL_VALUE, |
||
| 449 | 'required' => 0, |
||
| 450 | 'default' => 0, |
||
| 451 | 'print' => 1, |
||
| 452 | 'display_desc' => 1, |
||
| 453 | 'display_values' => 0, |
||
| 454 | 'display_placeholder' => 1, |
||
| 455 | 'custom' => 1, |
||
| 456 | ]; |
||
| 457 | $defaultSet[] = [ |
||
| 458 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 459 | 'caption' => \_AM_WGEVENTS_FIELD_CITY, |
||
| 460 | 'desc' => '', |
||
| 461 | 'values' => '', |
||
| 462 | 'placeholder' => \_AM_WGEVENTS_FIELD_CITY_VALUE, |
||
| 463 | 'required' => 0, |
||
| 464 | 'default' => 0, |
||
| 465 | 'print' => 1, |
||
| 466 | 'display_desc' => 1, |
||
| 467 | 'display_values' => 0, |
||
| 468 | 'display_placeholder' => 1, |
||
| 469 | 'custom' => 1, |
||
| 470 | ]; |
||
| 471 | $defaultSet[] = [ |
||
| 472 | 'type' => Constants::FIELD_COUNTRY, |
||
| 473 | 'caption' => \_AM_WGEVENTS_FIELD_COUNTRY, |
||
| 474 | 'desc' => '', |
||
| 475 | 'values' => '', |
||
| 476 | 'placeholder' => \_AM_WGEVENTS_FIELD_COUNTRY_VALUE, |
||
| 477 | 'required' => 0, |
||
| 478 | 'default' => 0, |
||
| 479 | 'print' => 1, |
||
| 480 | 'display_desc' => 1, |
||
| 481 | 'display_values' => 0, |
||
| 482 | 'display_placeholder' => 0, |
||
| 483 | 'custom' => 1, |
||
| 484 | ]; |
||
| 485 | $defaultSet[] = [ |
||
| 486 | 'type' => Constants::FIELD_DATE, |
||
| 487 | 'caption' => \_AM_WGEVENTS_FIELD_BIRTHDAY, |
||
| 488 | 'desc' => '', |
||
| 489 | 'values' => '', |
||
| 490 | 'placeholder' => \_AM_WGEVENTS_FIELD_BIRTHDAY_VALUE, |
||
| 491 | 'required' => 0, |
||
| 492 | 'default' => 0, |
||
| 493 | 'print' => 1, |
||
| 494 | 'display_desc' => 1, |
||
| 495 | 'display_values' => 0, |
||
| 496 | 'display_placeholder' => 0, |
||
| 497 | 'custom' => 1, |
||
| 498 | ]; |
||
| 499 | $defaultSet[] = [ |
||
| 500 | 'type' => Constants::FIELD_TEXTBOX, |
||
| 501 | 'caption' => \_AM_WGEVENTS_FIELD_AGE, |
||
| 502 | 'desc' => '', |
||
| 503 | 'values' => '', |
||
| 504 | 'placeholder' => \_AM_WGEVENTS_FIELD_AGE_VALUE, |
||
| 505 | 'required' => 0, |
||
| 506 | 'default' => 0, |
||
| 507 | 'print' => 1, |
||
| 508 | 'display_desc' => 1, |
||
| 509 | 'display_values' => 0, |
||
| 510 | 'display_placeholder' => 1, |
||
| 511 | 'custom' => 1, |
||
| 512 | ]; |
||
| 513 | |||
| 514 | return $defaultSet; |
||
| 515 | } |
||
| 516 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: