MCMatters/laravel-helpers

View on GitHub
src/Helpers/DbHelper.php

Summary

Maintainability
B
5 hrs
Test Coverage
F
32%

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

    public static function getAllTables(
        bool $withColumns = true,
        ?string $connection = null,
    ): array {
        $tables = [];
Severity: Minor
Found in src/Helpers/DbHelper.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 transformSqlBinding has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static function transformSqlBinding(mixed $binding): float|int|string
    {
        switch (gettype($binding)) {
            case 'boolean':
            case 'integer':
Severity: Minor
Found in src/Helpers/DbHelper.php - About 1 hr to fix

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

        public static function hasQueryJoinWith(object $query, string $with): bool
        {
            if (method_exists($query, 'getBaseQuery')) {
                $baseQuery = $query->getBaseQuery();
            } elseif (method_exists($query, 'getQuery')) {
    Severity: Minor
    Found in src/Helpers/DbHelper.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 $binding->format('Y-m-d H:i:s');
    Severity: Major
    Found in src/Helpers/DbHelper.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return '';
      Severity: Major
      Found in src/Helpers/DbHelper.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return self::escapeString((string) $binding);
        Severity: Major
        Found in src/Helpers/DbHelper.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return self::escapeString((string) $binding);
          Severity: Major
          Found in src/Helpers/DbHelper.php - About 30 mins to fix

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

                public static function searchEntireDatabase(
                    string $keyword,
                    ?string $connection = null,
                ): array {
                    $results = [];
            Severity: Minor
            Found in src/Helpers/DbHelper.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