jaroslavtyc/drd-plus-tables

View on GitHub
tests/Tables/Body/MovementTypes/MovementTypesTableTest.php

Summary

Maintainability
A
3 hrs
Test Coverage

The class MovementTypesTableTest has 21 public methods. Consider refactoring MovementTypesTableTest to keep number of public methods under 10.
Open

class MovementTypesTableTest extends TableTest
{
    private \DrdPlus\Tables\Measurements\Speed\SpeedTable $speedTable;
    private \DrdPlus\Tables\Measurements\Time\TimeTable $timeTable;

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

MovementTypesTableTest has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class MovementTypesTableTest extends TableTest
{
    private \DrdPlus\Tables\Measurements\Speed\SpeedTable $speedTable;
    private \DrdPlus\Tables\Measurements\Time\TimeTable $timeTable;

Severity: Minor
Found in tests/Tables/Body/MovementTypes/MovementTypesTableTest.php - About 2 hrs to fix

    Method I_can_get_all_values has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function I_can_get_all_values(): void
        {
            $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
            self::assertSame(
                [
    Severity: Minor
    Found in tests/Tables/Body/MovementTypes/MovementTypesTableTest.php - About 1 hr to fix

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

              } else {
                  self::assertSame($expectedPeriod, $movementTypesTable->getPeriodForPointOfFatigueOn($type));
              }

      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 '\DrdPlus\Tables\Tables' in method 'I_can_get_fatigue_on_rush'.
      Open

                  Tables::getIt()

      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 '\DrdPlus\Tables\Tables' in method 'I_can_get_fatigue_on_run'.
      Open

                  Tables::getIt()

      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 '\DrdPlus\Tables\Tables' in method 'I_can_get_fatigue_on_walk'.
      Open

                  Tables::getIt()

      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 '\DrdPlus\Tables\Tables' in method 'I_can_get_fatigue_on_sprint'.
      Open

                  Tables::getIt()

      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 I_can_get_period_for_point_fatigue_on_sprint_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_period_for_point_fatigue_on_sprint_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new Time(2, TimeUnitCode::ROUND, $this->timeTable), $movementTypesTable->getPeriodForPointOfFatigueOnSprint());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_not_get_period_of_fatigue_for_unknown_type is not named in camelCase.
      Open

          public function I_can_not_get_period_of_fatigue_for_unknown_type(): void
          {
              $this->expectException(\DrdPlus\Tables\Body\MovementTypes\Exceptions\UnknownMovementType::class);
              $this->expectExceptionMessageMatches('~sneaking~');
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_maximum_time_of_sprint is not named in camelCase.
      Open

          public function I_can_get_maximum_time_of_sprint(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              $timeBonus = $movementTypesTable->getMaximumTimeBonusToSprint($this->createEndurance(123));
              self::assertSame(123, $timeBonus->getValue());

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_fatigue_on_sprint is not named in camelCase.
      Open

          public function I_can_get_fatigue_on_sprint(): void
          {
              $fatigueOnRun = Tables::getIt()->getMovementTypesTable()->getFatigueOnSprint(
                  new Time(56, Time::MINUTE, Tables::getIt()->getTimeTable()),
                  Tables::getIt()

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_period_for_point_fatigue_on_walk_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_period_for_point_fatigue_on_walk_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new Time(1, TimeUnitCode::HOUR, $this->timeTable), $movementTypesTable->getPeriodForPointOfFatigueOnWalk());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_period_for_point_fatigue_on_run_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_period_for_point_fatigue_on_run_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new Time(5, TimeUnitCode::MINUTE, $this->timeTable), $movementTypesTable->getPeriodForPointOfFatigueOnRun());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_speed_bonus_on_walk_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_speed_bonus_on_walk_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new SpeedBonus(23, $this->speedTable), $movementTypesTable->getSpeedBonusOnWalk());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_all_values is not named in camelCase.
      Open

          public function I_can_get_all_values(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertSame(
                  [

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_speed_bonus_on_rush_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_speed_bonus_on_rush_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new SpeedBonus(26, $this->speedTable), $movementTypesTable->getSpeedBonusOnRush());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_speed_bonus_on_waiting_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_speed_bonus_on_waiting_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new SpeedBonus(0, $this->speedTable), $movementTypesTable->getSpeedBonusOnWaiting());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_period_for_point_fatigue_on_rush_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_period_for_point_fatigue_on_rush_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new Time(0.5, TimeUnitCode::HOUR, $this->timeTable), $movementTypesTable->getPeriodForPointOfFatigueOnRush());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_not_get_movement_bonus_for_unknown_type is not named in camelCase.
      Open

          public function I_can_not_get_movement_bonus_for_unknown_type(): void
          {
              $this->expectException(\DrdPlus\Tables\Body\MovementTypes\Exceptions\UnknownMovementType::class);
              $this->expectExceptionMessageMatches('~moonwalk~');
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_fatigue_on_walk is not named in camelCase.
      Open

          public function I_can_get_fatigue_on_walk(): void
          {
              $fatigueOnWalk = Tables::getIt()->getMovementTypesTable()->getFatigueOnWalk(
                  new Time(5, Time::HOUR, Tables::getIt()->getTimeTable()),
                  Tables::getIt()

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_fatigue_on_rush is not named in camelCase.
      Open

          public function I_can_get_fatigue_on_rush(): void
          {
              $fatigueOnRush = Tables::getIt()->getMovementTypesTable()->getFatigueOnRush(
                  new Time(5, Time::HOUR, Tables::getIt()->getTimeTable()),
                  Tables::getIt()

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_fatigue_on_run is not named in camelCase.
      Open

          public function I_can_get_fatigue_on_run(): void
          {
              $fatigueOnRun = Tables::getIt()->getMovementTypesTable()->getFatigueOnRun(
                  new Time(5, Time::HOUR, Tables::getIt()->getTimeTable()),
                  Tables::getIt()

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_header is not named in camelCase.
      Open

          public function I_can_get_header(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertSame(
                  [

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_speed_bonus_on_sprint_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_speed_bonus_on_sprint_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new SpeedBonus(36, $this->speedTable), $movementTypesTable->getSpeedBonusOnSprint());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_bonus_and_time_per_point_of_fatigue is not named in camelCase.
      Open

          public function I_can_get_bonus_and_time_per_point_of_fatigue(string $type, SpeedBonus $expectedBonus, $expectedPeriod): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
              self::assertEquals($expectedBonus, $movementTypesTable->getSpeedBonus($type));

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_speed_bonus_on_run_by_simple_getter is not named in camelCase.
      Open

          public function I_can_get_speed_bonus_on_run_by_simple_getter(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              self::assertEquals(new SpeedBonus(32, $this->speedTable), $movementTypesTable->getSpeedBonusOnRun());
          }

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      The method I_can_get_required_time_of_walk_after_maximum_sprint is not named in camelCase.
      Open

          public function I_can_get_required_time_of_walk_after_maximum_sprint(): void
          {
              $movementTypesTable = new MovementTypesTable($this->speedTable, $this->timeTable);
              $timeBonus = $movementTypesTable->getRequiredTimeBonusToWalkAfterFullSprint($this->createEndurance(456));
              self::assertSame(476, $timeBonus->getValue());

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status