symplely/hyper

View on GitHub
Request/Hyper.php

Summary

Maintainability
D
1 day
Test Coverage

File Hyper.php has 522 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

declare(strict_types=1);

namespace Async\Request;
Severity: Major
Found in Request/Hyper.php - About 1 day to fix

    Method sendRequest has 110 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

        public function sendRequest(RequestInterface $request) // Can't use `ResponseInterface` return type, cause method contains `yield`
        {
            $option = self::OPTIONS;
            $method = $request->getMethod();
    
    
    Severity: Major
    Found in Request/Hyper.php - About 4 hrs to fix

      Function sendRequest has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

          public function sendRequest(RequestInterface $request) // Can't use `ResponseInterface` return type, cause method contains `yield`
          {
              $option = self::OPTIONS;
              $method = $request->getMethod();
      
      
      Severity: Minor
      Found in Request/Hyper.php - About 3 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

      Function request has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function request($method, $url, $body = null, array ...$authorizeHeaderOptions): RequestInterface
          {
              $headerOptions = $this->optionsHeaderSplicer($authorizeHeaderOptions);
              $defaultOptions = self::OPTIONS;
              $defaultHeaders = self::HEADERS;
      Severity: Minor
      Found in Request/Hyper.php - About 3 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

      Hyper has 25 functions (exceeds 20 allowed). Consider refactoring.
      Wontfix

      class Hyper implements HyperInterface
      {
          /**
           * Set of key => value pairs to include as default headers with request calls.
           *
      Severity: Minor
      Found in Request/Hyper.php - About 2 hrs to fix

        Method request has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

            public function request($method, $url, $body = null, array ...$authorizeHeaderOptions): RequestInterface
            {
                $headerOptions = $this->optionsHeaderSplicer($authorizeHeaderOptions);
                $defaultOptions = self::OPTIONS;
                $defaultHeaders = self::HEADERS;
        Severity: Major
        Found in Request/Hyper.php - About 2 hrs to fix

          Function authorization has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function authorization(array $authorize = null): string
              {
                  if (empty($authorize))
                      return '';
          
          
          Severity: Minor
          Found in Request/Hyper.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

          Function selectSendRequest has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function selectSendRequest(
                  RequestInterface $request,
                  int $attempts = \RETRY_ATTEMPTS,
                  float $timeout = \RETRY_TIMEOUT,
                  bool $withTimeout = false
          Severity: Minor
          Found in Request/Hyper.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 waitController has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

              protected static function waitController()
              {
                  /**
                   * Check and handle request tasks already completed before entering/executing, fetch()/wait().
                   */
          Severity: Minor
          Found in Request/Hyper.php - About 1 hr to fix

            Method selectSendRequest has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Wontfix

                public function selectSendRequest(
                    RequestInterface $request,
                    int $attempts = \RETRY_ATTEMPTS,
                    float $timeout = \RETRY_TIMEOUT,
                    bool $withTimeout = false
            Severity: Minor
            Found in Request/Hyper.php - About 1 hr to fix

              Method optionsHeaderSplicer has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Wontfix

                  protected function optionsHeaderSplicer(array ...$headersOptions): array
                  {
                      $headersOptions = $headersOptions[0];
                      $header['headers'] = $authorizer = $headers = $options = [];
                      if (isset($headersOptions[0][0])) {
              Severity: Minor
              Found in Request/Hyper.php - About 1 hr to fix

                Function waitController has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected static function waitController()
                    {
                        /**
                         * Check and handle request tasks already completed before entering/executing, fetch()/wait().
                         */
                Severity: Minor
                Found in Request/Hyper.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 optionsHeaderSplicer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function optionsHeaderSplicer(array ...$headersOptions): array
                    {
                        $headersOptions = $headersOptions[0];
                        $header['headers'] = $authorizer = $headers = $options = [];
                        if (isset($headersOptions[0][0])) {
                Severity: Minor
                Found in Request/Hyper.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

                There are no issues that match your filters.

                Category
                Status