samsonos/php_activerecord

View on GitHub
src/dbMySQL.php

Summary

Maintainability
F
3 days
Test Coverage

File dbMySQL.php has 401 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace samson\activerecord;

use samsonframework\orm\QueryInterface;
use samsonframework\orm\ConditionInterface;
Severity: Minor
Found in src/dbMySQL.php - About 5 hrs to fix

    Function toRecords has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function &toRecords($class_name, array & $response, array $join = array(), array $virtual_fields = array())
        {
            // Сформируем правильное имя класса
            $class_name = strpos($class_name, '\\') !== false ? $class_name : '\\samson\activerecord\\'.$class_name;
    
    
    Severity: Minor
    Found in src/dbMySQL.php - About 5 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 toRecords has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function &toRecords($class_name, array & $response, array $join = array(), array $virtual_fields = array())
        {
            // Сформируем правильное имя класса
            $class_name = strpos($class_name, '\\') !== false ? $class_name : '\\samson\activerecord\\'.$class_name;
    
    
    Severity: Major
    Found in src/dbMySQL.php - About 2 hrs to fix

      Function prepareSQL has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function prepareSQL($class_name, QueryInterface $query)
          {
              //elapsed( 'dbMySQL::find() Начало');
              $params = $this->__get_table_data($class_name);
              // Получим переменные для запроса
      Severity: Minor
      Found in src/dbMySQL.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 parseCondition has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function parseCondition($class_name, & $arg)
          {
              // Получим переменные для запроса
              extract($this->__get_table_data($class_name));
      
      
      Severity: Minor
      Found in src/dbMySQL.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 prepareSQL has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function prepareSQL($class_name, QueryInterface $query)
          {
              //elapsed( 'dbMySQL::find() Начало');
              $params = $this->__get_table_data($class_name);
              // Получим переменные для запроса
      Severity: Minor
      Found in src/dbMySQL.php - About 1 hr to fix

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

            public function migration($classname, $version_handler)
            {
                if (!is_callable($version_handler)) {
                    return e('No version handler is passed', E_SAMSON_ACTIVERECORD_ERROR);
                }
        Severity: Minor
        Found in src/dbMySQL.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 __get_table_data has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __get_table_data($class_name)
            {
                // Remove table prefix
                $class_name = str_replace(self::$prefix, '', $class_name);
        
        
        Severity: Minor
        Found in src/dbMySQL.php - About 1 hr to fix

          Method parseCondition has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function parseCondition($class_name, & $arg)
              {
                  // Получим переменные для запроса
                  extract($this->__get_table_data($class_name));
          
          
          Severity: Minor
          Found in src/dbMySQL.php - About 1 hr to fix

            Function createObject has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function &createObject(
                    $className,
                    $identifier,
                    array & $attributes,
                    array & $dbData,
            Severity: Minor
            Found in src/dbMySQL.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 createField has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function createField($object, $table, $field, $type = 'INT')
                {
                    // Check if db identifier field is configured
                    if (class_exists($table)) {
                        if (strlen($object->$field)) {
            Severity: Minor
            Found in src/dbMySQL.php - About 45 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

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

                    $className,
                    $identifier,
                    array & $attributes,
                    array & $dbData,
                    array & $virtualFields = array()
            Severity: Minor
            Found in src/dbMySQL.php - About 35 mins to fix

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

                  protected function &getQueryFields($className, & $object = null, $straight = false)
                  {
                      // Результирующая коллекция
                      $collection = array();
              
              
              Severity: Minor
              Found in src/dbMySQL.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 '1 = 0';
              Severity: Major
              Found in src/dbMySQL.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                        return $sql_cond_t . ' NOT ' . $sql_values;
                Severity: Major
                Found in src/dbMySQL.php - About 30 mins to fix

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

                      protected function getConditions(ConditionInterface $cond_group, $class_name)
                      {
                          // Соберем сюда все сформированные условия для удобной "упаковки" их в строку
                          $sql_condition = array();
                  
                  
                  Severity: Minor
                  Found in src/dbMySQL.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