gomoob/php-websocket-server

View on GitHub
src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method testAuthorizeSend has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testAuthorizeSend()
    {
        // Test without metadata parameters on request
        $this->assertFalse(
            ApplicationsAuthManager::factory()->authorizeSend(
Severity: Major
Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 2 hrs to fix

    Method testAuthorizeOpen has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testAuthorizeOpen()
        {
            // Test without specifying `authorizeOpen` explicitly
            $this->assertTrue(ApplicationsAuthManager::factory()->authorizeOpen($this->createIoConnection()));
            
    Severity: Major
    Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 2 hrs to fix

      Method testConstruct has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testConstruct()
          {
              $ioConnection = $this->createIoConnection();
              $webSocketRequest = WebSocketRequest::factory('Hello World !');
      
      
      Severity: Minor
      Found in src/test/php/Gomoob/WebSocket/Auth/ApplicationsAuthManagerTest.php - About 1 hr to fix

        Missing class import via use statement (line '287', column '40').
        Open

                $ioConnection->WebSocket = new \stdClass();

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

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

                $webSocketRequest = WebSocketRequest::factory('Hello World !');

        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 'testAuthorizeSend'.
        Open

                        WebSocketRequest::factory('Hello !')

        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 unused local variables such as '$webSocketRequest'.
        Open

                $webSocketRequest = WebSocketRequest::factory('Hello World !');

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

        Avoid unused local variables such as '$ioConnection'.
        Open

                $ioConnection = $this->createIoConnection();

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

        Avoid unused local variables such as '$authManager'.
        Open

                $authManager = new ApplicationsAuthManager();

        UnusedLocalVariable

        Since: 0.2

        Detects when a local variable is declared and/or assigned, but not used.

        Example

        class Foo {
            public function doSomething()
            {
                $i = 5; // Unused
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

        There are no issues that match your filters.

        Category
        Status