| Conditions | 2 |
| Paths | 2 |
| Total Lines | 331 |
| Code Lines | 260 |
| 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 |
||
| 444 | private function getUnionCloudErrorDetails($errorCode) |
||
| 445 | {
|
||
| 446 | $errors = [ |
||
| 447 | '401' => [ |
||
| 448 | IncorrectRequestParameterException::class, |
||
| 449 | 401, |
||
| 450 | 'Invalid Email or Password' |
||
| 451 | ], |
||
| 452 | '402' => [ |
||
| 453 | IncorrectRequestParameterException::class, |
||
| 454 | 401, |
||
| 455 | 'Invalid App ID or Password' |
||
| 456 | ], |
||
| 457 | '403' => [ |
||
| 458 | IncorrectRequestParameterException::class, |
||
| 459 | 401, |
||
| 460 | 'You need further API permissions' |
||
| 461 | ], |
||
| 462 | '404' => [ |
||
| 463 | IncorrectRequestParameterException::class, |
||
| 464 | 500, |
||
| 465 | 'Unknown error authenticating' |
||
| 466 | ], |
||
| 467 | '405' => [ |
||
| 468 | IncorrectRequestParameterException::class, |
||
| 469 | 401, |
||
| 470 | 'Authentication parameters missing' |
||
| 471 | ], |
||
| 472 | '413' => [ |
||
| 473 | IncorrectRequestParameterException::class, |
||
| 474 | 429, |
||
| 475 | 'Too many requests' |
||
| 476 | ], |
||
| 477 | 'ERR101' => [ |
||
| 478 | IncorrectRequestParameterException::class, |
||
| 479 | 400, |
||
| 480 | 'Something went wrong with your email' |
||
| 481 | ], |
||
| 482 | 'ERR102' => [ |
||
| 483 | IncorrectRequestParameterException::class, |
||
| 484 | 400, |
||
| 485 | 'Something went wrong with your forename' |
||
| 486 | ], |
||
| 487 | 'ERR103' => [ |
||
| 488 | IncorrectRequestParameterException::class, |
||
| 489 | 400, |
||
| 490 | 'Something went wrong with your surname' |
||
| 491 | ], |
||
| 492 | 'ERR104' => [ |
||
| 493 | IncorrectRequestParameterException::class, |
||
| 494 | 400, |
||
| 495 | 'Something went wrong with your DoB' |
||
| 496 | ], |
||
| 497 | 'ERR105' => [ |
||
| 498 | IncorrectRequestParameterException::class, |
||
| 499 | 400, |
||
| 500 | 'Something went wrong with your gender' |
||
| 501 | ], |
||
| 502 | 'ERR106' => [ |
||
| 503 | IncorrectRequestParameterException::class, |
||
| 504 | 400, |
||
| 505 | 'Something went wrong with your additional identities' |
||
| 506 | ], |
||
| 507 | 'ERR107' => [ |
||
| 508 | IncorrectRequestParameterException::class, |
||
| 509 | 400, |
||
| 510 | 'Something went wrong with your institution email' |
||
| 511 | ], |
||
| 512 | 'ERR108' => [ |
||
| 513 | IncorrectRequestParameterException::class, |
||
| 514 | 400, |
||
| 515 | 'Something went wrong with your student ID' |
||
| 516 | ], |
||
| 517 | 'ERR109' => [ |
||
| 518 | IncorrectRequestParameterException::class, |
||
| 519 | 400, |
||
| 520 | 'Something went wrong with your nationality' |
||
| 521 | ], |
||
| 522 | 'ERR110' => [ |
||
| 523 | IncorrectRequestParameterException::class, |
||
| 524 | 400, |
||
| 525 | 'Something went wrong with your Domicile Country' |
||
| 526 | ], |
||
| 527 | 'ERR111' => [ |
||
| 528 | IncorrectRequestParameterException::class, |
||
| 529 | 400, |
||
| 530 | 'Something went wrong with your fee status' |
||
| 531 | ], |
||
| 532 | 'ERR112' => [ |
||
| 533 | IncorrectRequestParameterException::class, |
||
| 534 | 400, |
||
| 535 | 'Something went wrong with your study type' |
||
| 536 | ], |
||
| 537 | 'ERR113' => [ |
||
| 538 | IncorrectRequestParameterException::class, |
||
| 539 | 400, |
||
| 540 | 'Something went wrong with your programme level' |
||
| 541 | ], |
||
| 542 | 'ERR114' => [ |
||
| 543 | IncorrectRequestParameterException::class, |
||
| 544 | 400, |
||
| 545 | 'Something went wrong with your course end date' |
||
| 546 | ], |
||
| 547 | 'ERR115' => [ |
||
| 548 | IncorrectRequestParameterException::class, |
||
| 549 | 400, |
||
| 550 | 'Something went wrong with your alternate email address' |
||
| 551 | ], |
||
| 552 | 'ERR116' => [ |
||
| 553 | IncorrectRequestParameterException::class, |
||
| 554 | 400, |
||
| 555 | 'Something went wrong with your library card' |
||
| 556 | ], |
||
| 557 | 'ERR117' => [ |
||
| 558 | IncorrectRequestParameterException::class, |
||
| 559 | 400, |
||
| 560 | 'Something went wrong with your erasmus status' |
||
| 561 | ], |
||
| 562 | 'ERR118' => [ |
||
| 563 | IncorrectRequestParameterException::class, |
||
| 564 | 400, |
||
| 565 | 'Something went wrong with your finalist status' |
||
| 566 | ], |
||
| 567 | 'ERR119' => [ |
||
| 568 | IncorrectRequestParameterException::class, |
||
| 569 | 400, |
||
| 570 | 'Something went wrong with your mode of study' |
||
| 571 | ], |
||
| 572 | 'ERR120' => [ |
||
| 573 | IncorrectRequestParameterException::class, |
||
| 574 | 400, |
||
| 575 | 'Something went wrong with your placement status' |
||
| 576 | ], |
||
| 577 | 'ERR121' => [ |
||
| 578 | IncorrectRequestParameterException::class, |
||
| 579 | 400, |
||
| 580 | 'Something went wrong with your record type' |
||
| 581 | ], |
||
| 582 | 'ERR122' => [ |
||
| 583 | IncorrectRequestParameterException::class, |
||
| 584 | 404, |
||
| 585 | 'No user found' |
||
| 586 | ], |
||
| 587 | 'ERR123' => [ |
||
| 588 | IncorrectRequestParameterException::class, |
||
| 589 | 400, |
||
| 590 | 'Something went wrong with your NUS communication status' |
||
| 591 | ], |
||
| 592 | 'ERR124' => [ |
||
| 593 | IncorrectRequestParameterException::class, |
||
| 594 | 400, |
||
| 595 | 'Something went wrong with your NUS commercial communication status' |
||
| 596 | ], |
||
| 597 | 'ERR125' => [ |
||
| 598 | IncorrectRequestParameterException::class, |
||
| 599 | 400, |
||
| 600 | 'Something went wrong with your union communication status' |
||
| 601 | ], |
||
| 602 | 'ERR126' => [ |
||
| 603 | IncorrectRequestParameterException::class, |
||
| 604 | 400, |
||
| 605 | 'Something went wrong with your union commercial communication status' |
||
| 606 | ], |
||
| 607 | 'ERR127' => [ |
||
| 608 | IncorrectRequestParameterException::class, |
||
| 609 | 400, |
||
| 610 | 'Something went wrong with your terms and conditions' |
||
| 611 | ], |
||
| 612 | 'ERR201' => [ |
||
| 613 | ResourceNotFoundException::class, |
||
| 614 | 404, |
||
| 615 | 'Group ID wasn\'t found' |
||
| 616 | ], |
||
| 617 | 'ERR203' => [ |
||
| 618 | IncorrectRequestParameterException::class, |
||
| 619 | 404, |
||
| 620 | 'Membership type ID not found or approved' |
||
| 621 | ], |
||
| 622 | 'ERR205' => [ |
||
| 623 | IncorrectRequestParameterException::class, |
||
| 624 | 400, |
||
| 625 | 'Next of Kin forename can\'t be blank' |
||
| 626 | ], |
||
| 627 | 'ERR206' => [ |
||
| 628 | IncorrectRequestParameterException::class, |
||
| 629 | 400, |
||
| 630 | 'Next of Kin surname can\'t be blank' |
||
| 631 | ], |
||
| 632 | 'ERR207' => [ |
||
| 633 | IncorrectRequestParameterException::class, |
||
| 634 | 400, |
||
| 635 | 'Next of Kin relationship can\'t be blank' |
||
| 636 | ], |
||
| 637 | 'ERR208' => [ |
||
| 638 | IncorrectRequestParameterException::class, |
||
| 639 | 400, |
||
| 640 | 'Next of Kin address can\'t be blank' |
||
| 641 | ], |
||
| 642 | 'ERR209' => [ |
||
| 643 | IncorrectRequestParameterException::class, |
||
| 644 | 400, |
||
| 645 | 'Next of Kin home phone can\'t be blank' |
||
| 646 | ], |
||
| 647 | 'ERR212' => [ |
||
| 648 | IncorrectRequestParameterException::class, |
||
| 649 | 400, |
||
| 650 | 'You need to be over 18 to join this group' |
||
| 651 | ], |
||
| 652 | 'ERR213' => [ |
||
| 653 | IncorrectRequestParameterException::class, |
||
| 654 | 400, |
||
| 655 | 'Please answer all mandatory questions' |
||
| 656 | ], |
||
| 657 | 'ERR301' => [ |
||
| 658 | IncorrectRequestParameterException::class, |
||
| 659 | 400, |
||
| 660 | 'Something went wrong with the UserGroup name' |
||
| 661 | ], |
||
| 662 | 'ERR302' => [ |
||
| 663 | ResourceNotFoundException::class, |
||
| 664 | 400, |
||
| 665 | 'Folder can\'t be found' |
||
| 666 | ], |
||
| 667 | 'ERR304' => [ |
||
| 668 | ResourceNotFoundException::class, |
||
| 669 | 404, |
||
| 670 | 'UserGroup can\'t be found' |
||
| 671 | ], |
||
| 672 | 'ERR305' => [ |
||
| 673 | IncorrectRequestParameterException::class, |
||
| 674 | 400, |
||
| 675 | 'Unable to delete - contains a reference to another resource' |
||
| 676 | ], |
||
| 677 | 'ERR306' => [ |
||
| 678 | IncorrectRequestParameterException::class, |
||
| 679 | 400, |
||
| 680 | 'Unable to delete - system generated UserGroup' |
||
| 681 | ], |
||
| 682 | 'ERR307' => [ |
||
| 683 | IncorrectRequestParameterException::class, |
||
| 684 | 400, |
||
| 685 | 'Unable to delete - folder not empty' |
||
| 686 | ], |
||
| 687 | 'ERR308' => [ |
||
| 688 | IncorrectRequestParameterException::class, |
||
| 689 | 400, |
||
| 690 | 'Expiry date is required' |
||
| 691 | ], |
||
| 692 | 'ERR309' => [ |
||
| 693 | IncorrectRequestParameterException::class, |
||
| 694 | 400, |
||
| 695 | 'UID is required' |
||
| 696 | ], |
||
| 697 | 'ERR310' => [ |
||
| 698 | IncorrectRequestParameterException::class, |
||
| 699 | 404, |
||
| 700 | 'UserGroup not found' |
||
| 701 | ], |
||
| 702 | 'ERR311' => [ |
||
| 703 | IncorrectRequestParameterException::class, |
||
| 704 | 400, |
||
| 705 | 'Cannot modify this UserGroups UserGroup Memberships' |
||
| 706 | ], |
||
| 707 | 'ERR312' => [ |
||
| 708 | IncorrectRequestParameterException::class, |
||
| 709 | 400, |
||
| 710 | 'UserGroup Membership already exists' |
||
| 711 | ], |
||
| 712 | 'ERR313' => [ |
||
| 713 | IncorrectRequestParameterException::class, |
||
| 714 | 404, |
||
| 715 | 'UserGroup Membership ID not found' |
||
| 716 | ], |
||
| 717 | 'ERR501' => [ |
||
| 718 | IncorrectRequestParameterException::class, |
||
| 719 | 400, |
||
| 720 | 'Event name cannot be more than 255 characters' |
||
| 721 | ], |
||
| 722 | 'ERR502' => [ |
||
| 723 | IncorrectRequestParameterException::class, |
||
| 724 | 400, |
||
| 725 | 'Event Type ID is mandatory' |
||
| 726 | ], |
||
| 727 | 'ERR503' => [ |
||
| 728 | IncorrectRequestParameterException::class, |
||
| 729 | 400, |
||
| 730 | 'Start date not valid' |
||
| 731 | ], |
||
| 732 | 'ERR504' => [ |
||
| 733 | IncorrectRequestParameterException::class, |
||
| 734 | 400, |
||
| 735 | 'End date not valid' |
||
| 736 | ], |
||
| 737 | 'ERR505' => [ |
||
| 738 | IncorrectRequestParameterException::class, |
||
| 739 | 400, |
||
| 740 | 'Description is required, and can\'t be longer than 8000 characters' |
||
| 741 | ], |
||
| 742 | 'ERR506' => [ |
||
| 743 | IncorrectRequestParameterException::class, |
||
| 744 | 400, |
||
| 745 | 'Event name is mandatory' |
||
| 746 | ], |
||
| 747 | 'ERR507' => [ |
||
| 748 | IncorrectRequestParameterException::class, |
||
| 749 | 400, |
||
| 750 | 'Contact details are mandatory' |
||
| 751 | ], |
||
| 752 | 'ERR508' => [ |
||
| 753 | IncorrectRequestParameterException::class, |
||
| 754 | 400, |
||
| 755 | 'The capaciy is incorrect' |
||
| 756 | ], |
||
| 757 | 'ERR511' => [ |
||
| 758 | IncorrectRequestParameterException::class, |
||
| 759 | 400, |
||
| 760 | 'Published date should be in the future' |
||
| 761 | ], |
||
| 762 | ]; |
||
| 763 | |||
| 764 | if(array_key_exists($errorCode, $errors)) |
||
| 765 | {
|
||
| 766 | $error = $errors[$errorCode]; |
||
| 767 | return [ |
||
| 768 | 'errorClass' => $error[0], |
||
| 769 | 'code' => $error[1], |
||
| 770 | 'message' => $error[2] |
||
| 771 | ]; |
||
| 772 | } |
||
| 773 | |||
| 774 | return false; |
||
| 775 | } |
||
| 974 | } |