artur-graniszewski/ZEUS-for-PHP

View on GitHub
src/Zeus/ServerService/Http/Message/Message.php

Summary

Maintainability
D
1 day
Test Coverage

File Message.php has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Zeus\ServerService\Http\Message;

use Zeus\ServerService\Http\Message\Helper\ChunkedEncoding;
Severity: Minor
Found in src/Zeus/ServerService/Http/Message/Message.php - About 5 hrs to fix

    Message has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Message implements MessageComponentInterface, HeartBeatMessageInterface
    {
        use ChunkedEncoding;
        use RegularEncoding;
        use FileUpload;
    Severity: Minor
    Found in src/Zeus/ServerService/Http/Message/Message.php - About 2 hrs to fix

      Function sendBody has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function sendBody(ConnectionInterface $connection, $buffer)
          {
              if ($this->isBodyAllowedInResponse($this->request)) {
                  $isChunkedResponse = $this->response->getMetadata('isChunkedResponse');
      
      
      Severity: Minor
      Found in src/Zeus/ServerService/Http/Message/Message.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 onMessage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function onMessage(ConnectionInterface $connection, $message)
          {
              $this->requestPhase = static::REQUEST_PHASE_READING;
      
              if (!$this->headersReceived) {
      Severity: Minor
      Found in src/Zeus/ServerService/Http/Message/Message.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 enableCompressionIfSupported has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function enableCompressionIfSupported(& $buffer)
          {
              $this->compressionHandler = null;
      
              if (!function_exists('deflate_init') || !$this->isBodyAllowedInResponse($this->request)) {
      Severity: Minor
      Found in src/Zeus/ServerService/Http/Message/Message.php - About 1 hr to fix

        Method onMessage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function onMessage(ConnectionInterface $connection, $message)
            {
                $this->requestPhase = static::REQUEST_PHASE_READING;
        
                if (!$this->headersReceived) {
        Severity: Minor
        Found in src/Zeus/ServerService/Http/Message/Message.php - About 1 hr to fix

          Function enableCompressionIfSupported has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function enableCompressionIfSupported(& $buffer)
              {
                  $this->compressionHandler = null;
          
                  if (!function_exists('deflate_init') || !$this->isBodyAllowedInResponse($this->request)) {
          Severity: Minor
          Found in src/Zeus/ServerService/Http/Message/Message.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 sendResponse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function sendResponse($buffer)
              {
                  $connection = $this->connection;
          
                  if (!$this->headersSent) {
          Severity: Minor
          Found in src/Zeus/ServerService/Http/Message/Message.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 false;
          Severity: Major
          Found in src/Zeus/ServerService/Http/Message/Message.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true;
            Severity: Major
            Found in src/Zeus/ServerService/Http/Message/Message.php - About 30 mins to fix

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

                  protected function sendHeaders(& $buffer)
                  {
                      $connection = $this->connection;
                      $this->request->setMetadata('remoteAddress', $connection->getRemoteAddress());
                      $response = $this->response;
              Severity: Minor
              Found in src/Zeus/ServerService/Http/Message/Message.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