jaroslavtyc/drd-plus-therugist-spells

View on GitHub
DrdPlus/Theurgist/Spells/SpellParameters/FormulaDifficultyAddition.php

Summary

Maintainability
B
6 hrs
Test Coverage

Showing 14 of 14 total issues

Avoid using static access to class '\Granam\Integer\Tools\ToInteger' in method 'sub'.
Open

$this->getValue() - ToInteger::toInteger($value) // current addition is injected as second parameter

Avoid using static access to class '\Granam\Scalar\Tools\ToString' in method '__construct'.
Open

$parts = $this->parseParts(ToString::toString($difficultyAdditionByRealmsNotation));

Avoid using static access to class '\Granam\Integer\Tools\ToInteger' in method 'sanitizeRealms'.
Open

return ToInteger::toPositiveInteger($realmIncrement);

Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'sanitizeAddition'.
Open

'Expected integer for addition by realm, got ' . ValueDescriber::describe($addition)

Avoid using static access to class '\Granam\Tools\ValueDescriber' in method '__construct'.
Open

. ValueDescriber::describe($difficultyAdditionByRealmsNotation)

Avoid using static access to class '\Granam\Integer\Tools\ToInteger' in method 'add'.
Open

$this->getValue() + ToInteger::toInteger($value) // current addition is injected as second parameter

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

} else {
throw new Exceptions\InvalidFormatOfAdditionByRealmsNotation(
"Expected addition by realms in format 'number' or 'number=number', got "
. ValueDescriber::describe($difficultyAdditionByRealmsNotation)
);

Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'sanitizeRealms'.
Open

'Expected positive integer for realms increment , got ' . ValueDescriber::describe($realmIncrement)

Avoid using static access to class '\Granam\Integer\Tools\ToInteger' in method 'sanitizeAddition'.
Open

return ToInteger::toInteger($addition);

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

public function __construct($difficultyAdditionByRealmsNotation, int $currentAddition = null)
{
$parts = $this->parseParts(ToString::toString($difficultyAdditionByRealmsNotation));
if (\count($parts) === 1 && \array_keys($parts) === [0]) {
$this->realmsChangePerAdditionStep = 1;
DrdPlus/Theurgist/Spells/SpellParameters/AdditionByDifficulty.php on lines 33..49

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

private $realmsChangePerAdditionStep;

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

private $difficultyAdditionPerStep;

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

public function __construct($difficultyAdditionByRealmsNotation, int $currentAddition = null)

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

private function parseParts(string $additionByRealmNotation): array

There are no issues that match your filters.

Category
Status