gomoob/php-websocket-server

View on GitHub
src/test/php/Gomoob/WebSocket/Request/WebSocketRequestTest.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method testCreateFromArray has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testCreateFromArray()
    {
        $messageParser = new MessageParser();
        
        // Test with bad keys
Severity: Major
Found in src/test/php/Gomoob/WebSocket/Request/WebSocketRequestTest.php - About 4 hrs to fix

    Method testCreateFromJSON has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testCreateFromJSON()
        {
            $messageParser = new MessageParser();
            
            // Test with an invalid JSON string
    Severity: Minor
    Found in src/test/php/Gomoob/WebSocket/Request/WebSocketRequestTest.php - About 1 hr to fix

      The method testCreateFromArray() has 125 lines of code. Current threshold is set to 100. Avoid really long methods.
      Open

          public function testCreateFromArray()
          {
              $messageParser = new MessageParser();
              
              // Test with bad keys

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromArray'.
      Open

                  WebSocketRequest::createFromArray(
                      [
                          'message' => [
                              'a' => 'b'
                          ],

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromArray'.
      Open

                  WebSocketRequest::createFromArray(
                      [
                          'tags' => [
                              'tag1' => 'tag1Value',
                              'tag2' => 'tag2Value'

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromArray'.
      Open

              $webSocketRequest = WebSocketRequest::createFromArray(
                  [
                      'message' => [
                          'type' => 'MY_TYPE',
                          'metadata' => [

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromJSON'.
      Open

                  WebSocketRequest::createFromJSON(654, $messageParser);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromJSON'.
      Open

              $webSocketRequest = WebSocketRequest::createFromJSON(
                  '{
                      "message" : {
                          "type" : "MY_TYPE",
                          "metadata" : {

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromArray'.
      Open

                  WebSocketRequest::createFromArray(
                      [
                          'message' => [
                              'type' => 'MY_TYPE',
                              'metadata' => [

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class '\Gomoob\WebSocket\Request\WebSocketRequest' in method 'testCreateFromArray'.
      Open

                  WebSocketRequest::createFromArray(['badKey' => 'value'], $messageParser);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      There are no issues that match your filters.

      Category
      Status