MCMatters/laravel-helpers

View on GitHub

Showing 23 of 23 total issues

Function hasWithWildcard has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public static function hasWithWildcard(
        array $array,
        string $keys,
        bool $searchWithSegment = false,
    ): bool {
Severity: Minor
Found in src/Helpers/ArrayHelper.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 hasWithWildcard has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function hasWithWildcard(
        array $array,
        string $keys,
        bool $searchWithSegment = false,
    ): bool {
Severity: Major
Found in src/Helpers/ArrayHelper.php - About 2 hrs to fix

    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 contains has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function contains(
              array $array,
              string $needle,
              bool $byKey = false,
          ): bool {
      Severity: Minor
      Found in src/Helpers/ArrayHelper.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

      Function compileParameters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function compileParameters(array $parameters): string
          {
              $compiled = [];
      
              foreach ($parameters as $key => $value) {
      Severity: Minor
      Found in src/Helpers/ArtisanHelper.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 doesMorphedBelongToParent has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              Model $morphed,
              Model $parent,
              string $name,
              ?string $type = null,
              ?string $id = null,
      Severity: Minor
      Found in src/Helpers/ModelHelper.php - About 35 mins to fix

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

                mixed $json,
                bool $return = false,
                bool $assoc = false,
                int $depth = 512,
                int $options = 0,
        Severity: Minor
        Found in src/Helpers/TypeHelper.php - About 35 mins to fix

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

                  Model $morphed,
                  Model $parent,
                  string $name,
                  ?string $type = null,
                  ?string $id = null,
          Severity: Minor
          Found in src/functions/model.php - About 35 mins to fix

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

                    mixed $json,
                    bool $return = false,
                    bool $assoc = false,
                    int $depth = 512,
                    int $options = 0,
            Severity: Minor
            Found in src/functions/type.php - About 35 mins 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 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 '';
                  Severity: Major
                  Found in src/Helpers/DbHelper.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

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

                      Avoid too many return statements within this method.
                      Open

                                          return !empty($array);
                      Severity: Major
                      Found in src/Helpers/ArrayHelper.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

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

                            Avoid too many return statements within this method.
                            Open

                                            return false;
                            Severity: Major
                            Found in src/Helpers/ArrayHelper.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
                                Severity
                                Category
                                Status
                                Source
                                Language