bluetree-service/event

View on GitHub

Showing 15 of 15 total issues

File EventDispatcherTest.php has 406 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * test Event Dispatcher class
 *
Severity: Minor
Found in test/EventDispatcherTest.php - About 5 hrs to fix

    The class EventDispatcherTest has 22 public methods. Consider refactoring EventDispatcherTest to keep number of public methods under 10.
    Open

    class EventDispatcherTest extends TestCase
    {
        /**
         * name of test event log file
         */
    Severity: Minor
    Found in test/EventDispatcherTest.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    EventDispatcherTest has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class EventDispatcherTest extends TestCase
    {
        /**
         * name of test event log file
         */
    Severity: Minor
    Found in test/EventDispatcherTest.php - About 3 hrs to fix

      Method testSetEventDispatcherConfiguration has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function testSetEventDispatcherConfiguration($options)
          {
              $eventDispatcher = new EventDispatcher;
              $eventDispatcher->setEventConfiguration($options['events']);
      
      
      Severity: Minor
      Found in test/EventDispatcherTest.php - About 1 hr to fix

        Method testTriggerMultipleEvents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testTriggerMultipleEvents()
            {
                $testData = [];
                $instance = new EventDispatcher(['events' => [
                    'test_event' => [
        Severity: Minor
        Found in test/EventDispatcherTest.php - About 1 hr to fix

          Missing class import via use statement (line '525', column '19').
          Open

                  throw new \Exception('Test error');
          Severity: Minor
          Found in test/EventDispatcherTest.php by phpmd

          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

          The method logAllEvents has a boolean flag argument $log, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public function logAllEvents(bool $log = true): self
          Severity: Minor
          Found in src/Event/Base/EventDispatcher.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

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

          Missing class import via use statement (line '222', column '23').
          Open

                      throw new \InvalidArgumentException('File ' . $path . 'don\'t exists.');
          Severity: Minor
          Found in src/Event/Base/EventDispatcher.php by phpmd

          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

          Missing class import via use statement (line '228', column '23').
          Open

                      throw new \InvalidArgumentException('Incorrect configuration type: ' . $type);
          Severity: Minor
          Found in src/Event/Base/EventDispatcher.php by phpmd

          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

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

                      'log_object'        => new \SimpleLog\Log,
          Severity: Minor
          Found in test/EventDispatcherTest.php by phpmd

          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

          Missing class import via use statement (line '102', column '23').
          Open

                      throw new \LogicException('Invalid interface of event object');
          Severity: Minor
          Found in src/Event/Base/EventDispatcher.php by phpmd

          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

          Missing class import via use statement (line '95', column '23').
          Open

                      throw new \InvalidArgumentException('Event is not defined.');
          Severity: Minor
          Found in src/Event/Base/EventDispatcher.php by phpmd

          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 '\BlueEvent\Event\BaseEvent' in method 'testEventLaunchCount'.
          Open

                  $this->assertEquals(0, \BlueEvent\Event\BaseEvent::getLaunchCount());
          Severity: Minor
          Found in test/BaseEventTest.php by phpmd

          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

          The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $this->loggerInstance = new Log($this->options['log_config']);
                  }
          Severity: Minor
          Found in src/Event/Base/EventLog.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

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

          Avoid using static access to class '\BlueEvent\Event\BaseEvent' in method 'testEventLaunchCount'.
          Open

                  $this->assertEquals(2, \BlueEvent\Event\BaseEvent::getLaunchCount());
          Severity: Minor
          Found in test/BaseEventTest.php by phpmd

          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

          Severity
          Category
          Status
          Source
          Language