comsave/salesforce-mapper-bundle

View on GitHub
src/LogicItLab/Salesforce/MapperBundle/Mapper.php

Summary

Maintainability
F
4 days
Test Coverage
F
55%

File Mapper.php has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace LogicItLab\Salesforce\MapperBundle;

use DateTime;
Severity: Minor
Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 7 hrs to fix

    Function mapToSalesforceObject has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        public function mapToSalesforceObject($model)
        {
            $sObject = new stdClass;
            $sObject->fieldsToNull = array();
    
    
    Severity: Minor
    Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 6 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

    Mapper has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mapper
    {
        /**
         * Salesforce client
         *
    Severity: Minor
    Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 3 hrs to fix

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

          public function getFields($modelClass, $includeRelatedLevels, $ignoreObject = null)
          {
              $fields = array();
      
              foreach ($this->annotationReader->getSalesforceFields($modelClass) as $field) {
      Severity: Minor
      Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.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 mapToSalesforceObject has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function mapToSalesforceObject($model)
          {
              $sObject = new stdClass;
              $sObject->fieldsToNull = array();
      
      
      Severity: Major
      Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 2 hrs to fix

        Function save has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function save($model)
            {
                if (is_array($model)) {
                    $models = $model;
                } elseif ($model instanceof Traversable) {
        Severity: Minor
        Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr 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 save has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function save($model)
            {
                if (is_array($model)) {
                    $models = $model;
                } elseif ($model instanceof Traversable) {
        Severity: Minor
        Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr to fix

          Function getQueryWherePart has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              private function getQueryWherePart(array $criteria, $model)
              {
                  $whereParts = array();
                  $object = $this->annotationReader->getSalesforceObject($model);
                  $fields = $this->annotationReader->getSalesforceFields($model);
          Severity: Minor
          Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr 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 getQueryWherePart has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function getQueryWherePart(array $criteria, $model)
              {
                  $whereParts = array();
                  $object = $this->annotationReader->getSalesforceObject($model);
                  $fields = $this->annotationReader->getSalesforceFields($model);
          Severity: Minor
          Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr to fix

            Method mapToDomainObject has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function mapToDomainObject($sObject, $modelClass)
                {
                    // Try to find mapped model in unit of work
                    if ($this->unitOfWork->find($modelClass, $sObject->Id)) {
                        return $this->unitOfWork->find($modelClass, $sObject->Id);
            Severity: Minor
            Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr to fix

              Method getQuotedWhereValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function getQuotedWhereValue(
                      Annotation\Field $field,
                      $value,
                      Result\DescribeSObjectResult $description
                  ) {
              Severity: Minor
              Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr to fix

                Function mapToDomainObject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function mapToDomainObject($sObject, $modelClass)
                    {
                        // Try to find mapped model in unit of work
                        if ($this->unitOfWork->find($modelClass, $sObject->Id)) {
                            return $this->unitOfWork->find($modelClass, $sObject->Id);
                Severity: Minor
                Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr 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 getFields has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getFields($modelClass, $includeRelatedLevels, $ignoreObject = null)
                    {
                        $fields = array();
                
                        foreach ($this->annotationReader->getSalesforceFields($modelClass) as $field) {
                Severity: Minor
                Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 1 hr to fix

                  Method findBy has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          $model,
                          array $criteria,
                          array $order = array(),
                          $related = 1,
                          $deleted = false,
                  Severity: Minor
                  Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 45 mins to fix

                    Method findOneBy has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            $model,
                            array $criteria,
                            array $order = array(),
                            $related = 2,
                            $deleted = false
                    Severity: Minor
                    Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 35 mins to fix

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

                          public function getOneToManySubqueries($model, $includeRelatedLevels)
                          {
                              $relations = $this->annotationReader->getSalesforceRelations($model);
                              $object = $this->annotationReader->getSalesforceObject($model);
                              $subqueries = array();
                      Severity: Minor
                      Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.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 "'" . addslashes($value) . "'";
                      Severity: Major
                      Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $value ? 'true' : 'false';
                        Severity: Major
                        Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $value;
                          Severity: Major
                          Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 30 mins to fix

                            Function getQuotedWhereValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function getQuotedWhereValue(
                                    Annotation\Field $field,
                                    $value,
                                    Result\DescribeSObjectResult $description
                                ) {
                            Severity: Minor
                            Found in src/LogicItLab/Salesforce/MapperBundle/Mapper.php - About 25 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

                            There are no issues that match your filters.

                            Category
                            Status