jaroslavtyc/drd-plus-codes

View on GitHub
tests/Codes/Armaments/MeleeWeaponCodeTest.php

Summary

Maintainability
F
4 days
Test Coverage

Function I_can_ask_code_if_is_specific_weapon_type has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    public function I_can_ask_code_if_is_specific_weapon_type()
    {
        $questions = [
            'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
            'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',
Severity: Minor
Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 1 day 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

File MeleeWeaponCodeTest.php has 442 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);

namespace DrdPlus\Tests\Codes\Armaments;

use DrdPlus\Codes\Armaments\Exceptions\CanNotBeConvertedToRangeWeaponCode;
Severity: Minor
Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 6 hrs to fix

    Method I_can_ask_code_if_is_specific_weapon_type has 107 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function I_can_ask_code_if_is_specific_weapon_type()
        {
            $questions = [
                'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',
    Severity: Major
    Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 4 hrs to fix

      The class MeleeWeaponCodeTest has an overall complexity of 61 which is very high. The configured complexity threshold is 50.
      Open

      class MeleeWeaponCodeTest extends WeaponCodeTest
      {
          use MeleeWeaponlikeCodeTrait;
      
          /**

      The class MeleeWeaponCodeTest has 24 public methods. Consider refactoring MeleeWeaponCodeTest to keep number of public methods under 10.
      Open

      class MeleeWeaponCodeTest extends WeaponCodeTest
      {
          use MeleeWeaponlikeCodeTrait;
      
          /**

      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

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

      class MeleeWeaponCodeTest extends WeaponCodeTest
      {
          use MeleeWeaponlikeCodeTrait;
      
          /**
      Severity: Minor
      Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 3 hrs to fix

        Method I_can_get_all_codes_at_once_or_by_same_named_constant has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function I_can_get_all_codes_at_once_or_by_same_named_constant()
            {
                self::assertSame(
                    $expectedValues = [
                        // unarmed
        Severity: Major
        Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php - About 2 hrs to fix

          The method I_can_ask_code_if_is_specific_weapon_type() has an NPath complexity of 393216. The configured NPath complexity threshold is 200.
          Open

              public function I_can_ask_code_if_is_specific_weapon_type()
              {
                  $questions = [
                      'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                      'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

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

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

              public function I_can_ask_code_if_is_specific_weapon_type()
              {
                  $questions = [
                      'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                      'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',

          The method I_can_ask_code_if_is_specific_weapon_type() has a Cyclomatic Complexity of 30. The configured cyclomatic complexity threshold is 10.
          Open

              public function I_can_ask_code_if_is_specific_weapon_type()
              {
                  $questions = [
                      'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                      'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

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

          Missing class import via use statement (line '540', column '32').
          Open

                  $reflectionClass = new \ReflectionClass(MeleeWeaponCode::class);

          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 '\DrdPlus\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_axe_codes'.
          Open

                      MeleeWeaponCode::getAxesValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_not_extended_it_by_same_code_but_different_category'.
          Open

                  MeleeWeaponCode::addNewMeleeWeaponCode('corge', $differentCategory, []);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_voulges_and_trident_codes'.
          Open

                      MeleeWeaponCode::getVoulgesAndTridentsValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_all_codes_at_once_or_by_same_named_constant'.
          Open

                      \count($missingOrDifferent = \array_diff_assoc($expectedValues, MeleeWeaponCode::getPossibleValues())) > 0

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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_ask_code_if_is_specific_weapon_type uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                              } else {
                                  self::assertTrue($code->$question());
                              }

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_not_convert_anything_to_melee_weapon_code'.
          Open

                  $wantItRange = MeleeWeaponCode::getIt(MeleeWeaponCode::CUDGEL);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_get_from_melee_code_negative_answer_to_most_range_question'.
          Open

                      $meleeWeaponCode = MeleeWeaponCode::getIt($meleeWeaponCode);

          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 '\Granam\String\StringTools' in method 'I_can_easily_composer_method_to_get_weapons_of_same_category'.
          Open

                      $getMeleeWeaponOfCategory = StringTools::assembleGetterForName($meleeWeaponCategoryValue . 'Values');

          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\Codes\Armaments\RangedWeaponCode' in method 'I_can_convert_spear_to_range_weapon_code'.
          Open

                  self::assertSame(RangedWeaponCode::getIt(RangedWeaponCode::SPEAR), $rangeSpear);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_easily_find_out_if_weapon_is_unarmed_in_fact'.
          Open

                      $meleeWeaponCode = MeleeWeaponCode::getIt($meleeWeaponCodeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_easily_find_out_if_weapon_is_unarmed_in_fact'.
          Open

                          \in_array($meleeWeaponCodeValue, MeleeWeaponCode::getUnarmedValues(), true),

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_unarmed_codes'.
          Open

                      MeleeWeaponCode::getUnarmedValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getAxesValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_not_extended_it_by_same_code_but_different_category'.
          Open

                  self::assertNotContains('corge', MeleeWeaponCode::getPossibleValues());

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getMorningstarsAndMorgensternsValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getUnarmedValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getStaffsAndSpearsValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getSwordsValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_saber_and_bowie_knife_codes'.
          Open

                      MeleeWeaponCode::getSabersAndBowieKnivesValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_all_codes_at_once_or_by_same_named_constant'.
          Open

                          : 'superfluous values or different keys in given: ' . \var_export(\array_diff_assoc(MeleeWeaponCode::getPossibleValues(), $expectedValues), true)

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_convert_spear_to_range_weapon_code'.
          Open

                  $meleeSpear = MeleeWeaponCode::getIt(MeleeWeaponCode::SPEAR);

          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\Codes\Armaments\WeaponCategoryCode' in method 'getWeaponCategoryValues'.
          Open

                  return WeaponCategoryCode::getMeleeWeaponCategoryValues();

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_sword_codes'.
          Open

                      MeleeWeaponCode::getSwordsValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_all_codes_at_once_or_by_same_named_constant'.
          Open

                      MeleeWeaponCode::getPossibleValues(),

          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\Codes\Armaments\WeaponCategoryCode' in method 'I_can_not_add_new_melee_weapon_code_with_not_melee_category'.
          Open

                  $throwingCategory = WeaponCategoryCode::getIt(WeaponCategoryCode::THROWING_WEAPONS);

          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\Codes\Armaments\WeaponCategoryCode' in method 'I_can_easily_composer_method_to_get_weapons_of_same_category'.
          Open

                  foreach (WeaponCategoryCode::getMeleeWeaponCategoryValues() as $meleeWeaponCategoryValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getMacesAndClubsValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_easily_find_out_if_weapon_is_unarmed_in_fact'.
          Open

                      MeleeWeaponCode::getUnarmedValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getSabersAndBowieKnivesValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_get_from_melee_code_negative_answer_to_most_range_question'.
          Open

                  foreach (MeleeWeaponCode::getPossibleValues() as $meleeWeaponCode) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_not_extended_it_by_same_code_but_different_category'.
          Open

                      MeleeWeaponCode::addNewMeleeWeaponCode('corge', $someCategory = $this->getRandomWeaponCategoryCode(), [])

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_easily_find_out_if_weapon_is_unarmed_in_fact'.
          Open

                  foreach (MeleeWeaponCode::getPossibleValues() as $meleeWeaponCodeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_knife_and_dagger_codes'.
          Open

                      MeleeWeaponCode::getKnivesAndDaggersValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_staff_and_spear_codes'.
          Open

                      MeleeWeaponCode::getStaffsAndSpearsValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getVoulgesAndTridentsValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_mace_and_club_codes'.
          Open

                      MeleeWeaponCode::getMacesAndClubsValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_get_morningstar_and_morgenstern_codes'.
          Open

                      MeleeWeaponCode::getMorningstarsAndMorgensternsValues()

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                  foreach (MeleeWeaponCode::getKnivesAndDaggersValues() as $codeValue) {

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_ask_code_if_is_specific_weapon_type'.
          Open

                      $code = MeleeWeaponCode::getIt($codeValue);

          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\Codes\Armaments\MeleeWeaponCode' in method 'I_can_not_add_new_melee_weapon_code_with_not_melee_category'.
          Open

                  MeleeWeaponCode::addNewMeleeWeaponCode('foo', $throwingCategory, []);

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function I_can_not_extended_it_by_same_code_but_different_category()
              {
                  $this->expectException(\DrdPlus\Codes\Armaments\Exceptions\MeleeWeaponIsAlreadyInDifferentWeaponCategory::class);
                  $reflectionClass = new \ReflectionClass(MeleeWeaponCode::class);
                  $translations = $reflectionClass->getProperty('translations');
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 1 other location - About 4 hrs to fix
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 304..320

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 173.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              public function I_can_convert_spear_to_range_weapon_code()
              {
                  $meleeSpear = MeleeWeaponCode::getIt(MeleeWeaponCode::SPEAR);
                  self::assertInstanceOf(MeleeWeaponCode::class, $meleeSpear);
                  self::assertSame($meleeSpear, $meleeSpear->convertToMeleeWeaponCodeEquivalent());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 1 other location - About 1 hr to fix
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 194..203

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 115.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getMorningstarsAndMorgensternsValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isMorningstarOrMorgenstern());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getSwordsValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isSword());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getUnarmedValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isUnarmed());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getAxesValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isAxe());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getKnivesAndDaggersValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isKnifeOrDagger());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getVoulgesAndTridentsValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isVoulgeOrTrident());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getSabersAndBowieKnivesValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isSaberOrBowieKnife());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 343..353
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 10 locations. Consider refactoring.
          Open

                  foreach (MeleeWeaponCode::getMacesAndClubsValues() as $codeValue) {
                      $code = MeleeWeaponCode::getIt($codeValue);
                      self::assertTrue($code->isMelee());
                      self::assertFalse($code->isRanged());
                      self::assertTrue($code->isMaceOrClub());
          Severity: Major
          Found in tests/Codes/Armaments/MeleeWeaponCodeTest.php and 9 other locations - About 40 mins to fix
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 321..331
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 332..342
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 354..364
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 365..375
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 391..401
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 402..412
          tests/Codes/Armaments/MeleeWeaponCodeTest.php on lines 413..423
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 153..163
          tests/Codes/Armaments/RangedWeaponCodeTest.php on lines 164..174

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 93.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Avoid excessively long variable names like $meleeWeaponCategoryValue. Keep variable name length under 20.
          Open

                  foreach (WeaponCategoryCode::getMeleeWeaponCategoryValues() as $meleeWeaponCategoryValue) {

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $canNotBeConvertedToRangeWeaponCode. Keep variable name length under 20.
          Open

                  } catch (CanNotBeConvertedToRangeWeaponCode $canNotBeConvertedToRangeWeaponCode) {

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $getMeleeWeaponOfCategory. Keep variable name length under 20.
          Open

                      $getMeleeWeaponOfCategory = StringTools::assembleGetterForName($meleeWeaponCategoryValue . 'Values');

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          The method I_can_get_saber_and_bowie_knife_codes is not named in camelCase.
          Open

              public function I_can_get_saber_and_bowie_knife_codes()
              {
                  self::assertSame(
                      [
                          'machete',

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

              public function I_can_not_add_new_melee_weapon_code_with_not_melee_category()
              {
                  $this->expectException(\DrdPlus\Codes\Armaments\Exceptions\InvalidWeaponCategoryForNewMeleeWeaponCode::class);
                  $this->expectExceptionMessageMatches('~throwing~');
                  $throwingCategory = WeaponCategoryCode::getIt(WeaponCategoryCode::THROWING_WEAPONS);

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

              public function I_can_get_it_with_default_value()
              {
                  $sut = $this->findSut();
                  self::assertSame(MeleeWeaponCode::HAND, $sut->getValue(), 'Expected bare hands as a default value');
              }

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

              public function I_can_get_sword_codes()
              {
                  self::assertSame(
                      [
                          'short_sword',

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

              public function I_can_not_extended_it_by_same_code_but_different_category()
              {
                  $this->expectException(\DrdPlus\Codes\Armaments\Exceptions\MeleeWeaponIsAlreadyInDifferentWeaponCategory::class);
                  $reflectionClass = new \ReflectionClass(MeleeWeaponCode::class);
                  $translations = $reflectionClass->getProperty('translations');

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

              public function I_can_easily_composer_method_to_get_weapons_of_same_category()
              {
                  foreach (WeaponCategoryCode::getMeleeWeaponCategoryValues() as $meleeWeaponCategoryValue) {
                      $getMeleeWeaponOfCategory = StringTools::assembleGetterForName($meleeWeaponCategoryValue . 'Values');
                      self::assertTrue(method_exists(self::getSutClass(), $getMeleeWeaponOfCategory));

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

              public function I_can_get_morningstar_and_morgenstern_codes()
              {
                  self::assertSame(
                      [
                          'light_morgenstern',

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

              public function I_can_easily_find_out_if_is_melee_weapon()
              {
                  self::assertTrue(MeleeWeaponCode::getIt(MeleeWeaponCode::CLUB)->isMeleeWeapon());
              }

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

              public function I_can_get_all_codes_at_once_or_by_same_named_constant()
              {
                  self::assertSame(
                      $expectedValues = [
                          // unarmed

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

              public function I_can_easily_find_out_if_is_melee()
              {
                  /** @var MeleeWeaponCode $sut */
                  $sut = $this->getSut();
                  self::assertTrue($sut->isMelee());

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

              public function I_can_get_axe_codes()
              {
                  self::assertSame(
                      [
                          'light_axe',

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

              public function I_can_get_voulges_and_trident_codes()
              {
                  self::assertSame(
                      [
                          'pitchfork',

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

              public function I_can_ask_code_if_is_specific_weapon_type()
              {
                  $questions = [
                      'isAxe', 'isKnifeOrDagger', 'isMaceOrClub', 'isMorningstarOrMorgenstern', 'isSaberOrBowieKnife',
                      'isStaffOrSpear', 'isSword', 'isVoulgeOrTrident', 'isUnarmed',

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

              public function I_get_from_melee_code_negative_answer_to_most_range_question()
              {
                  foreach (MeleeWeaponCode::getPossibleValues() as $meleeWeaponCode) {
                      $meleeWeaponCode = MeleeWeaponCode::getIt($meleeWeaponCode);
                      self::assertTrue($meleeWeaponCode->isMelee());

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

              public function I_can_get_knife_and_dagger_codes()
              {
                  self::assertSame(
                      [
                          'knife',

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

              public function I_can_convert_spear_to_range_weapon_code()
              {
                  $meleeSpear = MeleeWeaponCode::getIt(MeleeWeaponCode::SPEAR);
                  self::assertInstanceOf(MeleeWeaponCode::class, $meleeSpear);
                  self::assertSame($meleeSpear, $meleeSpear->convertToMeleeWeaponCodeEquivalent());

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

              public function I_can_easily_find_out_if_weapon_is_unarmed_in_fact()
              {
                  foreach (MeleeWeaponCode::getPossibleValues() as $meleeWeaponCodeValue) {
                      $meleeWeaponCode = MeleeWeaponCode::getIt($meleeWeaponCodeValue);
                      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_easily_find_out_if_is_shield is not named in camelCase.
          Open

              public function I_can_easily_find_out_if_is_shield()
              {
                  self::assertFalse(MeleeWeaponCode::getIt(MeleeWeaponCode::CLUB)->isShield());
              }

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

              public function I_can_easily_find_out_if_is_ranged()
              {
                  self::assertFalse(MeleeWeaponCode::getIt(MeleeWeaponCode::CUDGEL)->isRanged());
              }

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

              public function I_can_get_staff_and_spear_codes()
              {
                  self::assertSame(
                      [
                          'light_spear',

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

              public function I_can_get_unarmed_codes()
              {
                  self::assertSame(
                      [
                          'hand',

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

              public function It_is_melee_weapon_code()
              {
                  /** @var MeleeWeaponCode $sut */
                  $sut = $this->getSut();
                  self::assertInstanceOf(MeleeWeaponCode::class, $sut);

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

              public function I_can_not_convert_anything_to_melee_weapon_code()
              {
                  $this->expectException(\DrdPlus\Codes\Armaments\Exceptions\CanNotBeConvertedToRangeWeaponCode::class);
                  $this->expectExceptionMessageMatches('~cudgel~');
                  $wantItRange = MeleeWeaponCode::getIt(MeleeWeaponCode::CUDGEL);

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

              public function I_can_get_mace_and_club_codes()
              {
                  self::assertSame(
                      [
                          'cudgel',

          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