DerDu/SPHERE-Framework

View on GitHub
Application/Api/Contact/ApiAddressToPerson.php

Summary

Maintainability
F
6 days
Test Coverage

File ApiAddressToPerson.php has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Created by PhpStorm.
 * User: Kauschke
 * Date: 04.01.2019
Severity: Major
Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 day to fix

    ApiAddressToPerson has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ApiAddressToPerson  extends Extension implements IApiInterface
    {
    
        use ApiTrait;
    
    
    Severity: Minor
    Found in Application/Api/Contact/ApiAddressToPerson.php - About 3 hrs to fix

      Function saveEditAddressToPersonModal has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveEditAddressToPersonModal($PersonId, $ToPersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
          {
      
              if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                  return new Danger('Die Person wurde nicht gefunden', new Exclamation());
      Severity: Minor
      Found in Application/Api/Contact/ApiAddressToPerson.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function saveCreateAddressToPersonModal has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveCreateAddressToPersonModal($PersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
          {
      
              if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                  return new Danger('Die Person wurde nicht gefunden', new Exclamation());
      Severity: Minor
      Found in Application/Api/Contact/ApiAddressToPerson.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method openAddAddressToPersonModal has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function openAddAddressToPersonModal($PersonId, $ToPersonId)
          {
      
              if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                  return new Danger('Die Person wurde nicht gefunden', new Exclamation());
      Severity: Minor
      Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

        Method saveEditAddressToPersonModal has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveEditAddressToPersonModal($PersonId, $ToPersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
            {
        
                if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                    return new Danger('Die Person wurde nicht gefunden', new Exclamation());
        Severity: Minor
        Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

          Method saveCreateAddressToPersonModal has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function saveCreateAddressToPersonModal($PersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
              {
          
                  if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                      return new Danger('Die Person wurde nicht gefunden', new Exclamation());
          Severity: Minor
          Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

            Method openDeleteAddressToPersonModal has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function openDeleteAddressToPersonModal($PersonId, $ToPersonId)
                {
            
                    if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                        return new Danger('Die Person wurde nicht gefunden', new Exclamation());
            Severity: Minor
            Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

              Method saveEditAddressToPersonModal has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function saveEditAddressToPersonModal($PersonId, $ToPersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
              Severity: Major
              Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

                Method getAddressToPersonModal has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function getAddressToPersonModal($form, TblPerson $tblPerson,  $ToPersonId = null)
                    {
                        if ($ToPersonId) {
                            $title = new Title(new Edit() . ' Adresse bearbeiten');
                        } else {
                Severity: Minor
                Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

                  Method saveCreateAddressToPersonModal has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function saveCreateAddressToPersonModal($PersonId, $Street, $City, $State, $Type, $County, $Nation, $Relationship)
                  Severity: Major
                  Found in Application/Api/Contact/ApiAddressToPerson.php - About 1 hr to fix

                    Function loadRelationshipsMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function loadRelationshipsMessage($Relationship)
                        {
                    
                            if ($Relationship) {
                                foreach ($Relationship as $personId => $value) {
                    Severity: Minor
                    Found in Application/Api/Contact/ApiAddressToPerson.php - About 35 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Avoid too many return statements within this method.
                    Open

                                return new Danger('Die Adresse konnte nicht gespeichert werden.') . self::pipelineClose();
                    Severity: Major
                    Found in Application/Api/Contact/ApiAddressToPerson.php - About 30 mins to fix

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                          public function openDeleteAddressToPersonModal($PersonId, $ToPersonId)
                          {
                      
                              if (!($tblPerson = Person::useService()->getPersonById($PersonId))) {
                                  return new Danger('Die Person wurde nicht gefunden', new Exclamation());
                      Severity: Major
                      Found in Application/Api/Contact/ApiAddressToPerson.php and 1 other location - About 1 day to fix
                      Application/Api/Contact/ApiAddressToCompany.php on lines 354..388

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 342.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              if (Address::useService()->createAddressToPersonByApi($tblPerson, $Street, $City, $State, $Type, $County, $Nation)) {
                                  // Adresse für die ausgewählten Beziehungen speichern
                                  if (isset($Relationship)) {
                                      foreach ($Relationship as $personId => $value) {
                                          if (($tblPersonRelationship = Person::useService()->getPersonById($personId))) {
                      Severity: Major
                      Found in Application/Api/Contact/ApiAddressToPerson.php and 1 other location - About 5 hrs to fix
                      Application/Api/Contact/ApiAddressToPerson.php on lines 610..647

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 202.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                              if (Address::useService()->updateAddressToPersonByApi($tblToPerson, $Street, $City, $State, $Type, $County, $Nation)) {
                                  // Adresse für die ausgewählten Beziehungen speichern
                                  if (isset($Relationship)) {
                                      foreach ($Relationship as $personId => $value) {
                                          if (($tblPersonRelationship = Person::useService()->getPersonById($personId))) {
                      Severity: Major
                      Found in Application/Api/Contact/ApiAddressToPerson.php and 1 other location - About 5 hrs to fix
                      Application/Api/Contact/ApiAddressToPerson.php on lines 541..578

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 202.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      There are no issues that match your filters.

                      Category
                      Status