The class ShieldCodeTest has 11 public methods. Consider refactoring ShieldCodeTest to keep number of public methods under 10. Open
class ShieldCodeTest extends WeaponlikeCodeTest implements ProtectiveArmamentCodeTest
{
use MeleeWeaponlikeCodeTrait;
/**
- Read upRead up
- Exclude checks
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
Missing class import via use statement (line '58', column '27'). Open
$reflection = new \ReflectionClass(self::getSutClass());
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '46', column '27'). Open
$reflection = new \ReflectionClass(self::getSutClass());
- Read upRead up
- Exclude checks
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\ShieldCode' in method 'I_can_easily_find_out_if_is_protective_armament'. Open
$shieldCode = ShieldCode::getIt(ShieldCode::MEDIUM_SHIELD);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$interferingCodeClass'. Open
protected function isSameCodeAllowedFor(string $weaponlikeCode, string $interferingCodeClass): bool
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused parameters such as '$weaponlikeCode'. Open
protected function isSameCodeAllowedFor(string $weaponlikeCode, string $interferingCodeClass): bool
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
The method I_can_easily_find_out_if_is_protective_armament is not named in camelCase. Open
public function I_can_easily_find_out_if_is_protective_armament()
{
$shieldCode = ShieldCode::getIt(ShieldCode::MEDIUM_SHIELD);
self::assertTrue($shieldCode->isProtectiveArmament());
self::assertInstanceOf(ProtectiveArmamentCode::class, $shieldCode);
- Read upRead up
- Exclude checks
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()
{
self::assertTrue(ShieldCode::getIt(ShieldCode::WITHOUT_SHIELD)->isUnarmed());
self::assertFalse(ShieldCode::getIt(ShieldCode::HEAVY_SHIELD)->isUnarmed());
}
- Read upRead up
- Exclude checks
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()
{
$reflection = new \ReflectionClass(self::getSutClass());
/** @var ShieldCode $sut */
$sut = $reflection->newInstanceWithoutConstructor();
- Read upRead up
- Exclude checks
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_weapon is not named in camelCase. Open
public function I_can_easily_find_out_if_is_weapon()
{
$reflection = new \ReflectionClass(self::getSutClass());
/** @var ShieldCode $sut */
$sut = $reflection->newInstanceWithoutConstructor();
- Read upRead up
- Exclude checks
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_it_to_range_weapon_code is not named in camelCase. Open
public function I_can_not_convert_it_to_range_weapon_code()
{
$this->expectException(\DrdPlus\Codes\Armaments\Exceptions\CanNotBeConvertedToRangeWeaponCode::class);
ShieldCode::getIt(ShieldCode::BUCKLER)->convertToRangedWeaponCodeEquivalent();
}
- Read upRead up
- Exclude checks
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(ShieldCode::WITHOUT_SHIELD, $sut->getValue(), 'Expected without shield as a default value');
}
- Read upRead up
- Exclude checks
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::assertTrue(ShieldCode::getIt(ShieldCode::BUCKLER)->isShield());
self::assertFalse(ShieldCode::getIt(ShieldCode::BUCKLER)->isArmor());
}
- Read upRead up
- Exclude checks
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_it_is_not_projectile is not named in camelCase. Open
public function I_can_easily_find_out_it_is_not_projectile()
{
self::assertFalse(ShieldCode::getIt(ShieldCode::BUCKLER)->isProjectile());
}
- Read upRead up
- Exclude checks
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_it_to_melee_weapon_code is not named in camelCase. Open
public function I_can_not_convert_it_to_melee_weapon_code()
{
$this->expectException(\DrdPlus\Codes\Armaments\Exceptions\CanNotBeConvertedToMeleeWeaponCode::class);
ShieldCode::getIt(ShieldCode::BUCKLER)->convertToMeleeWeaponCodeEquivalent();
}
- Read upRead up
- Exclude checks
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::assertFalse(ShieldCode::getIt(ShieldCode::BUCKLER)->isMeleeWeapon());
}
- Read upRead up
- Exclude checks
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(ShieldCode::getIt(ShieldCode::WITHOUT_SHIELD)->isRanged());
}
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}