laravel/framework

View on GitHub
src/Illuminate/Http/Client/PendingRequest.php

Summary

Maintainability
F
3 days
Test Coverage

File PendingRequest.php has 720 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Http\Client;

use Closure;
Severity: Major
Found in src/Illuminate/Http/Client/PendingRequest.php - About 1 day to fix

    PendingRequest has 78 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PendingRequest
    {
        use Conditionable, Macroable;
    
        /**
    Severity: Major
    Found in src/Illuminate/Http/Client/PendingRequest.php - About 1 day to fix

      Method send has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function send(string $method, string $url, array $options = [])
          {
              if (! Str::startsWith($url, ['http://', 'https://'])) {
                  $url = ltrim(rtrim($this->baseUrl, '/').'/'.ltrim($url, '/'), '/');
              }
      Severity: Minor
      Found in src/Illuminate/Http/Client/PendingRequest.php - About 1 hr to fix

        Method handlePromiseResponse has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
            {
                if ($response instanceof Response && $response->successful()) {
                    return $response;
                }
        Severity: Minor
        Found in src/Illuminate/Http/Client/PendingRequest.php - About 1 hr to fix

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

              protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
              {
                  if ($response instanceof Response && $response->successful()) {
                      return $response;
                  }
          Severity: Minor
          Found in src/Illuminate/Http/Client/PendingRequest.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 handlePromiseResponse has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function handlePromiseResponse(Response|ConnectionException|TransferException $response, $method, $url, $options, $attempt)
          Severity: Minor
          Found in src/Illuminate/Http/Client/PendingRequest.php - About 35 mins to fix

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

                protected function parseHttpOptions(array $options)
                {
                    if (isset($options[$this->bodyFormat])) {
                        if ($this->bodyFormat === 'multipart') {
                            $options[$this->bodyFormat] = $this->parseMultipartBodyFormat($options[$this->bodyFormat]);
            Severity: Minor
            Found in src/Illuminate/Http/Client/PendingRequest.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 $response instanceof Response ? $response->toException() : $response;
            Severity: Major
            Found in src/Illuminate/Http/Client/PendingRequest.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $response;
              Severity: Major
              Found in src/Illuminate/Http/Client/PendingRequest.php - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status