Method getExpectedRacesToSubRaces
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getExpectedRacesToSubRaces(): array
{
return [
'human' => [
'common',
Function I_can_easily_find_out_if_sub_race_belongs_to_race
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function I_can_easily_find_out_if_sub_race_belongs_to_race()
{
foreach ($this->getExpectedRacesToSubRaces() as $race => $subRaces) {
$raceCode = RaceCode::getIt($race);
foreach ($subRaces as $subRace) {
- Read upRead up
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
Avoid using static access to class '\DrdPlus\Codes\RaceCode' in method 'I_can_easily_find_out_if_sub_race_belongs_to_race'. Open
$otherRaceCode = RaceCode::getIt($otherRace);
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_races_to_sub_races_codes'. Open
SubRaceCode::getPossibleValues(),
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_races_to_sub_races_codes'. Open
self::assertEquals(RaceCode::getPossibleValues(), array_keys(SubRaceCode::getRaceToSubRaceValues()));
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_races_to_sub_races_codes'. Open
array_merge(array_unique($this->toFlatValues(SubRaceCode::getRaceToSubRaceValues())))
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_easily_find_out_if_sub_race_belongs_to_race'. Open
$subRaceCode = SubRaceCode::getIt($subRace);
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_not_get_sub_race_default_to_an_unknown_race'. Open
$defaultOrcSubRace = SubRaceCode::getDefaultSubRaceFor($this->createRaceCode('rat-at-toullie'));
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_not_get_sub_race_default_to_an_unknown_race'. Open
self::assertSame(SubRaceCode::getIt(SubRaceCode::COMMON), $defaultOrcSubRace);
- 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 using static access to class '\DrdPlus\Codes\RaceCode' in method 'I_can_easily_find_out_if_sub_race_belongs_to_race'. Open
$otherRaces = \array_diff(RaceCode::getPossibleValues(), [$race]);
- 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 using static access to class '\DrdPlus\Codes\RaceCode' in method 'I_can_get_races_to_sub_races_codes'. Open
self::assertEquals(RaceCode::getPossibleValues(), array_keys(SubRaceCode::getRaceToSubRaceValues()));
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_sub_race_default_to_a_race'. Open
$defaultOrcSubRace = SubRaceCode::getDefaultSubRaceFor(RaceCode::getIt(RaceCode::ORC));
- 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 using static access to class '\DrdPlus\Codes\RaceCode' in method 'I_can_get_sub_race_default_to_a_race'. Open
$defaultOrcSubRace = SubRaceCode::getDefaultSubRaceFor(RaceCode::getIt(RaceCode::ORC));
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_sub_race_default_to_a_race'. Open
self::assertSame(SubRaceCode::getIt(SubRaceCode::COMMON), $defaultOrcSubRace);
- 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 using static access to class '\DrdPlus\Codes\SubRaceCode' in method 'I_can_get_races_to_sub_races_codes'. Open
self::assertEquals($this->getExpectedRacesToSubRaces(), SubRaceCode::getRaceToSubRaceValues());
- 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 using static access to class '\DrdPlus\Codes\RaceCode' in method 'I_can_easily_find_out_if_sub_race_belongs_to_race'. Open
$raceCode = RaceCode::getIt($race);
- 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
The method I_can_get_sub_race_default_to_a_race is not named in camelCase. Open
public function I_can_get_sub_race_default_to_a_race()
{
$defaultOrcSubRace = SubRaceCode::getDefaultSubRaceFor(RaceCode::getIt(RaceCode::ORC));
self::assertSame(SubRaceCode::getIt(SubRaceCode::COMMON), $defaultOrcSubRace);
}
- 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_sub_race_belongs_to_race is not named in camelCase. Open
public function I_can_easily_find_out_if_sub_race_belongs_to_race()
{
foreach ($this->getExpectedRacesToSubRaces() as $race => $subRaces) {
$raceCode = RaceCode::getIt($race);
foreach ($subRaces as $subRace) {
- 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_races_to_sub_races_codes is not named in camelCase. Open
public function I_can_get_races_to_sub_races_codes()
{
self::assertEquals($this->getExpectedRacesToSubRaces(), SubRaceCode::getRaceToSubRaceValues());
self::assertSame(
SubRaceCode::getPossibleValues(),
- 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_get_sub_race_default_to_an_unknown_race is not named in camelCase. Open
public function I_can_not_get_sub_race_default_to_an_unknown_race()
{
$this->expectException(\DrdPlus\Codes\Exceptions\UnknownRaceCode::class);
$this->expectExceptionMessageMatches('~rat-at-toullie~');
$defaultOrcSubRace = SubRaceCode::getDefaultSubRaceFor($this->createRaceCode('rat-at-toullie'));
- 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() {
}
}