php-yaoi/php-yaoi

View on GitHub
src/Database/Mysql/CreateTableReader.php

Summary

Maintainability
D
1 day
Test Coverage

File CreateTableReader.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Yaoi\Database\Mysql;

use Yaoi\BaseClass;
Severity: Minor
Found in src/Database/Mysql/CreateTableReader.php - About 2 hrs to fix

    Function parseLines has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        private function parseLines() {
            $this->columns = new \stdClass();
            $this->indexes = array();
            $this->foreignKeys = array();
    
    
    Severity: Minor
    Found in src/Database/Mysql/CreateTableReader.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 parseLines has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function parseLines() {
            $this->columns = new \stdClass();
            $this->indexes = array();
            $this->foreignKeys = array();
    
    
    Severity: Minor
    Found in src/Database/Mysql/CreateTableReader.php - About 1 hr to fix

      Method parseColumn has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function parseColumn(Parser $parser) {
              $columnName = $parser->inner(null, array(' ',"\r", "\n", "\t"));
              $columnName = (string)$this->resolve(trim($columnName));
      
              $type = (string)$parser->inner(null, ' ');
      Severity: Minor
      Found in src/Database/Mysql/CreateTableReader.php - About 1 hr to fix

        Method getTypeByString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getTypeByString($type) {
                $phpType = Column::STRING;
                $type = strtoupper($type);
                switch (true) {
                    case 'BIGINT' === substr($type, 0, 6):
        Severity: Minor
        Found in src/Database/Mysql/CreateTableReader.php - About 1 hr to fix

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

              private function parseColumn(Parser $parser) {
                  $columnName = $parser->inner(null, array(' ',"\r", "\n", "\t"));
                  $columnName = (string)$this->resolve(trim($columnName));
          
                  $type = (string)$parser->inner(null, ' ');
          Severity: Minor
          Found in src/Database/Mysql/CreateTableReader.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 getTypeByString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getTypeByString($type) {
                  $phpType = Column::STRING;
                  $type = strtoupper($type);
                  switch (true) {
                      case 'BIGINT' === substr($type, 0, 6):
          Severity: Minor
          Found in src/Database/Mysql/CreateTableReader.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 buildForeignKeys has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function buildForeignKeys() {
                  foreach ($this->foreignKeys as $data) {
                      $name = $data[0];
                      $localColumnNames = $data[1];
                      $localColumns = array();
          Severity: Minor
          Found in src/Database/Mysql/CreateTableReader.php - About 1 hr to fix

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

                private function parseConstraint(Parser $parser) {
                    $indexName = $this->resolve($parser->inner('CONSTRAINT', 'FOREIGN KEY', false, true));
                    $indexColumns = $parser->inner('(', ')')->explode(',');
                    foreach ($indexColumns as &$columnName) {
                        $columnName = $this->resolve($columnName);
            Severity: Minor
            Found in src/Database/Mysql/CreateTableReader.php - About 1 hr to fix

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

                  private function buildForeignKeys() {
                      foreach ($this->foreignKeys as $data) {
                          $name = $data[0];
                          $localColumnNames = $data[1];
                          $localColumns = array();
              Severity: Minor
              Found in src/Database/Mysql/CreateTableReader.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 parseConstraint has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function parseConstraint(Parser $parser) {
                      $indexName = $this->resolve($parser->inner('CONSTRAINT', 'FOREIGN KEY', false, true));
                      $indexColumns = $parser->inner('(', ')')->explode(',');
                      foreach ($indexColumns as &$columnName) {
                          $columnName = $this->resolve($columnName);
              Severity: Minor
              Found in src/Database/Mysql/CreateTableReader.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

              There are no issues that match your filters.

              Category
              Status