nabbar/SwaggerValidator-PHP

View on GitHub
src/Common/FactorySwagger.php

Summary

Maintainability
D
2 days
Test Coverage

File FactorySwagger.php has 327 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Minor
Found in src/Common/FactorySwagger.php - About 3 hrs to fix

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

        protected function buildObjectFromOriginObject(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
        {
            $keyIn   = self::KEY_IN;
            $keyName = self::KEY_NAME;
            $object  = null;
    Severity: Minor
    Found in src/Common/FactorySwagger.php - About 1 hr to fix

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

          protected function buildObjectFromOriginKey(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
          {
              $object = null;
      
              if (!empty(self::$keyToObject[$originKey])) {
      Severity: Minor
      Found in src/Common/FactorySwagger.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

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

          public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
          {
              $keyType   = self::KEY_TYPE;
              $keyCustom = self::KEY_CUSTOM_PATTERN;
              $notCustom = array(
      Severity: Minor
      Found in src/Common/FactorySwagger.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

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

          protected function buildObjectFromOriginObject(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
          {
              $keyIn   = self::KEY_IN;
              $keyName = self::KEY_NAME;
              $object  = null;
      Severity: Minor
      Found in src/Common/FactorySwagger.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 jsonUnSerialize has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function jsonUnSerialize(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
          {
              $keyType   = self::KEY_TYPE;
              $keyCustom = self::KEY_CUSTOM_PATTERN;
              $notCustom = array(
      Severity: Minor
      Found in src/Common/FactorySwagger.php - About 1 hr to fix

        Method buildObjectFromOriginKey has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function buildObjectFromOriginKey(\SwaggerValidator\Common\Context $context, $originType, $originKey, &$jsonData)
            {
                $object = null;
        
                if (!empty(self::$keyToObject[$originKey])) {
        Severity: Minor
        Found in src/Common/FactorySwagger.php - About 1 hr to fix

          Method SecurityDefinition has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function SecurityDefinition(\SwaggerValidator\Common\Context $context, &$jsonData)
              {
                  $typeKey = self::KEY_TYPE;
                  $flowKey = self::KEY_FLOW;
          
          Severity: Minor
          Found in src/Common/FactorySwagger.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if (!empty($originType) && !empty($originKey) && !in_array($originType, $notCustom) && substr($originKey, 0, strlen($keyCustom)) === $keyCustom) {
                        return $jsonData;
                    }
                    elseif (empty($originType) && !empty($originKey) && substr($originKey, 0, strlen($keyCustom)) === $keyCustom) {
                        return $jsonData;
            Severity: Major
            Found in src/Common/FactorySwagger.php - About 40 mins to fix

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

                  protected function returnBuildObject(\SwaggerValidator\Common\Context $context, \SwaggerValidator\Common\CollectionSwagger $object, $originType, $originKey, &$jsonData)
              Severity: Minor
              Found in src/Common/FactorySwagger.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $this->buildPrimitive($context, $originType, $originKey, $jsonData);
                Severity: Major
                Found in src/Common/FactorySwagger.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return 'TypeNumber';
                  Severity: Major
                  Found in src/Common/FactorySwagger.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                            return \SwaggerValidator\Common\Factory::getInstance()->OAuth2ApplicationSecurity;
                    Severity: Major
                    Found in src/Common/FactorySwagger.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return 'TypeObject';
                      Severity: Major
                      Found in src/Common/FactorySwagger.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return $this->returnBuildObject($context, \SwaggerValidator\Common\Factory::getInstance()->Reference, $originType, $originKey, $jsonData);
                        Severity: Major
                        Found in src/Common/FactorySwagger.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $jsonData;
                          Severity: Major
                          Found in src/Common/FactorySwagger.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return $this->returnBuildObject($context, \SwaggerValidator\Common\Factory::getInstance()->TypeObject, $originType, $originKey, $jsonData);
                            Severity: Major
                            Found in src/Common/FactorySwagger.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return 'TypeString';
                              Severity: Major
                              Found in src/Common/FactorySwagger.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return $jsonData;
                                Severity: Major
                                Found in src/Common/FactorySwagger.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                          return \SwaggerValidator\Common\Factory::getInstance()->OAuth2AccessCodeSecurity;
                                  Severity: Major
                                  Found in src/Common/FactorySwagger.php - About 30 mins to fix

                                    There are no issues that match your filters.

                                    Category
                                    Status