jaroslavtyc/drd-plus-therugist-spells

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

Summary

Maintainability
B
6 hrs
Test Coverage

Showing 16 of 16 total issues

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

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

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

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\InvalidFormatOfAdditionByDifficultyNotation(
"Expected addition by difficulty in format 'number' or 'number=number', got "
. ValueDescriber::describe($additionByDifficultyNotation)
);

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

return ToInteger::toInteger($addition);

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

'With zero step can not be an addition changed by ' . ValueDescriber::describe($value)

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

return ToInteger::toPositiveInteger($difficultyChange);

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

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

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

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

return ToInteger::toInteger(\ceil($this->getCurrentAddition() / $this->getAdditionStep() * $this->getDifficultyPerAdditionStep()));

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

'With zero step can not be an addition changed by ' . ValueDescriber::describe($value)

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

. ValueDescriber::describe($additionByDifficultyNotation)

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

'Expected positive integer for difficulty increment , got ' . ValueDescriber::describe($difficultyChange)

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

public function __construct($additionByDifficultyNotation, int $currentAddition = null)
{
$parts = $this->parseParts(ToString::toString($additionByDifficultyNotation));
if (\count($parts) === 1 && \array_keys($parts) === [0]) {
$this->difficultyPerAdditionStep = 1;
DrdPlus/Theurgist/Spells/SpellParameters/FormulaDifficultyAddition.php on lines 36..52

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

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

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

private $difficultyPerAdditionStep;

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

private function parseParts(string $additionByDifficultyNotation): array
Category
Status