laravel/framework

View on GitHub
src/Illuminate/Support/helpers.php

Summary

Maintainability
B
6 hrs
Test Coverage

File helpers.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use Illuminate\Contracts\Support\DeferringDisplayableValue;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\Support\Arr;
Severity: Minor
Found in src/Illuminate/Support/helpers.php - About 2 hrs to fix

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

        function retry($times, callable $callback, $sleepMilliseconds = 0, $when = null)
        {
            $attempts = 0;
    
            $backoff = [];
    Severity: Minor
    Found in src/Illuminate/Support/helpers.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 blank has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        function blank($value)
        {
            if (is_null($value)) {
                return true;
            }
    Severity: Minor
    Found in src/Illuminate/Support/helpers.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 object_get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        function object_get($object, $key, $default = null)
        {
            if (is_null($key) || trim($key) === '') {
                return $object;
            }
    Severity: Minor
    Found in src/Illuminate/Support/helpers.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

    Avoid too many return statements within this method.
    Open

            return empty($value);
    Severity: Major
    Found in src/Illuminate/Support/helpers.php - About 30 mins to fix

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

          function e($value, $doubleEncode = true)
          {
              if ($value instanceof DeferringDisplayableValue) {
                  $value = $value->resolveDisplayableValue();
              }
      Severity: Minor
      Found in src/Illuminate/Support/helpers.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

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

          function throw_if($condition, $exception = 'RuntimeException', ...$parameters)
          {
              if ($condition) {
                  if (is_string($exception) && class_exists($exception)) {
                      $exception = new $exception(...$parameters);
      Severity: Minor
      Found in src/Illuminate/Support/helpers.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