Thruio/ActiveRecord

View on GitHub
src/ActiveRecord.php

Summary

Maintainability
D
2 days
Test Coverage

File ActiveRecord.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Thru\ActiveRecord;

use Guzzle\Common\Version;
Severity: Minor
Found in src/ActiveRecord.php - About 6 hrs to fix

    ActiveRecord has 40 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class ActiveRecord
    {
        static public $MYSQL_FORMAT = "Y-m-d H:i:s";
        static public $showSql;
        protected $_label_column = null;
    Severity: Minor
    Found in src/ActiveRecord.php - About 5 hrs to fix

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

          public function save($automatic_reload = true)
          {
              // Run Pre-saver.
              $this->preSave();
      
      
      Severity: Minor
      Found in src/ActiveRecord.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 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function save($automatic_reload = true)
          {
              // Run Pre-saver.
              $this->preSave();
      
      
      Severity: Minor
      Found in src/ActiveRecord.php - About 1 hr to fix

        Function __calculateSaveDownRows has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __calculateSaveDownRows()
            {
                if (!$this->_columns) {
                    foreach (get_object_vars($this) as $potential_column => $discard) {
                        switch ($potential_column) {
        Severity: Minor
        Found in src/ActiveRecord.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 getClassSchema has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getClassSchema()
            {
                $current = get_class($this);
                $parents[] = $current;
                while ($current = get_parent_class($current)) {
        Severity: Minor
        Found in src/ActiveRecord.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 __parseClassSchemaProperty has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function __parseClassSchemaProperty($row)
            {
                $bits = explode(" ", $row);
                $name = trim($bits[1], "$");
                $type = $bits[2];
        Severity: Minor
        Found in src/ActiveRecord.php - About 1 hr to fix

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

              public function getClassSchema()
              {
                  $current = get_class($this);
                  $parents[] = $current;
                  while ($current = get_parent_class($current)) {
          Severity: Minor
          Found in src/ActiveRecord.php - About 1 hr to fix

            Function __parseClassSchemaProperty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function __parseClassSchemaProperty($row)
                {
                    $bits = explode(" ", $row);
                    $name = trim($bits[1], "$");
                    $type = $bits[2];
            Severity: Minor
            Found in src/ActiveRecord.php - About 55 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

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

                public function __fieldFix()
                {
                    $schema = $this->getClassSchema();
                    foreach ($this->__calculateSaveDownRows() as $column) {
                        if (!isset($schema[$column]['type'])) {
            Severity: Minor
            Found in src/ActiveRecord.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