File Formula.php
has 410 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
declare(strict_types=1);
namespace DrdPlus\Theurgist\Spells;
Formula
has 32 functions (exceeds 20 allowed). Consider refactoring.
class Formula extends StrictObject
{
use ToFlatArrayTrait;
The class Formula has an overall complexity of 79 which is very high. The configured complexity threshold is 50.
class Formula extends StrictObject
{
use ToFlatArrayTrait;
Function getParameterBonusFromModifiers
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
private function getParameterBonusFromModifiers(string $parameterName)
{
$bonusParts = [];
foreach ($this->modifiers as $modifier) {
if ($modifier->getModifierCode()->getValue() === ModifierCode::GATE) {
Method getCurrentDifficulty
has 35 lines of code (exceeds 25 allowed). Consider refactoring.
public function getCurrentDifficulty(): FormulaDifficulty
{
$formulaParameters = [
$this->getAttackWithAddition(),
$this->getBrightnessWithAddition(),
Method sanitizeSpellParameterChanges
has 34 lines of code (exceeds 25 allowed). Consider refactoring.
private function sanitizeSpellParameterChanges(array $spellParameterValues): array
{
$sanitizedChanges = [];
foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
if (!\array_key_exists($mutableSpellParameter, $spellParameterValues)) {
Method getParameterBonusFromModifiers
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
private function getParameterBonusFromModifiers(string $parameterName)
{
$bonusParts = [];
foreach ($this->modifiers as $modifier) {
if ($modifier->getModifierCode()->getValue() === ModifierCode::GATE) {
Function sanitizeSpellParameterChanges
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
private function sanitizeSpellParameterChanges(array $spellParameterValues): array
{
$sanitizedChanges = [];
foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
if (!\array_key_exists($mutableSpellParameter, $spellParameterValues)) {
Method __construct
has 6 arguments (exceeds 4 allowed). Consider refactoring.
FormulaCode $formulaCode,
FormulasTable $formulasTable,
DistanceTable $distanceTable,
array $formulaSpellParameterValues = [],
array $modifiers = [],
Function getRealmsAffectionsSum
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
private function getRealmsAffectionsSum(): array
{
$baseRealmsAffection = $this->formulasTable->getRealmsAffection($this->getFormulaCode());
$realmsAffectionsSum = [
The class Formula has a coupling between objects value of 38. Consider to reduce the number of dependencies under 13.
class Formula extends StrictObject
{
use ToFlatArrayTrait;
Avoid using static access to class '\Granam\String\StringTools' in method 'getParameterBonusFromModifiers'.
$getParameterWithAddition = StringTools::assembleGetterForName($parameterName . 'WithAddition');
Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'sanitizeSpellParameterChanges'.
'Expected integer, got ' . ValueDescriber::describe($spellParameterValues[$mutableSpellParameter])
Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'getCheckedSpellTraits'.
'Expected instance of ' . Modifier::class . ', got ' . ValueDescriber::describe($spellTrait)
Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'getCheckedModifiers'.
'Expected instance of ' . Modifier::class . ', got ' . ValueDescriber::describe($modifier)
Avoid using static access to class '\DrdPlus\Codes\Theurgist\FormulaMutableSpellParameterCode' in method 'sanitizeSpellParameterChanges'.
foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
Avoid using static access to class '\Granam\String\StringTools' in method 'sanitizeSpellParameterChanges'.
$getParameter = StringTools::assembleGetterForName($mutableSpellParameter);
Avoid using static access to class '\Granam\Integer\Tools\ToInteger' in method 'sanitizeSpellParameterChanges'.
$sanitizedValue = ToInteger::toInteger($spellParameterValues[$mutableSpellParameter]);
Avoid using static access to class '\DrdPlus\Codes\Theurgist\FormulaMutableSpellParameterCode' in method 'sanitizeSpellParameterChanges'.
. \implode(', ', FormulaMutableSpellParameterCode::getPossibleValues())
Avoid using static access to class '\Granam\Tools\ValueDescriber' in method 'sanitizeSpellParameterChanges'.
. ', so given non-zero addition ' . ValueDescriber::describe($spellParameterValues[$mutableSpellParameter])
Similar blocks of code found in 2 locations. Consider refactoring.
public function getCurrentSpellSpeed(): ?SpellSpeed
{
$spellSpeedWithAddition = $this->getSpellSpeedWithAddition();
$spellSpeedBonus = $this->getParameterBonusFromModifiers(ModifierMutableSpellParameterCode::SPELL_SPEED);
if (!$spellSpeedWithAddition && $spellSpeedBonus === false) {
Similar blocks of code found in 2 locations. Consider refactoring.
public function getCurrentPower(): ?Power
{
$powerWithAddition = $this->getPowerWithAddition();
$powerBonus = $this->getParameterBonusFromModifiers(ModifierMutableSpellParameterCode::POWER);
if (!$powerWithAddition && $powerBonus === false) {
Avoid excessively long variable names like $modifierRealmsAffection. Keep variable name length under 20.
$modifierRealmsAffection = $modifier->getRealmsAffection();
Avoid excessively long variable names like $epicenterShiftByModifiers. Keep variable name length under 20.
$epicenterShiftByModifiers = $this->getParameterBonusFromModifiers(ModifierMutableSpellParameterCode::EPICENTER_SHIFT);
Avoid excessively long variable names like $getParameterWithAddition. Keep variable name length under 20.
$getParameterWithAddition = StringTools::assembleGetterForName($parameterName . 'WithAddition');
Avoid excessively long variable names like $formulaSpellParameterChanges. Keep variable name length under 20.
private $formulaSpellParameterChanges;
Avoid excessively long variable names like $parametersDifficultyChangeSum. Keep variable name length under 20.
$parametersDifficultyChangeSum = 0;
Avoid excessively long variable names like $radiusModifiersChange. Keep variable name length under 20.
$radiusModifiersChange = $this->getParameterBonusFromModifiers(ModifierMutableSpellParameterCode::RADIUS);
Avoid excessively long variable names like $spellSpeedWithAddition. Keep variable name length under 20.
$spellSpeedWithAddition = $this->getSpellSpeedWithAddition();
Avoid excessively long variable names like $formulaSpellParameterValues. Keep variable name length under 20.
array $formulaSpellParameterValues = [],
Avoid excessively long variable names like $mutableSpellParameter. Keep variable name length under 20.
foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
Avoid excessively long variable names like $modifierRealmsAffectionPeriod. Keep variable name length under 20.
$modifierRealmsAffectionPeriod = $modifierRealmsAffection->getAffectionPeriod()->getValue();
Avoid excessively long variable names like $epicenterShiftWithAddition. Keep variable name length under 20.
$epicenterShiftWithAddition = $this->getEpicenterShiftWithAddition();
Avoid excessively long variable names like $spellTraitsDifficultyChangeSum. Keep variable name length under 20.
$spellTraitsDifficultyChangeSum = 0;
Avoid excessively long variable names like $byModifierRequiredRealm. Keep variable name length under 20.
$byModifierRequiredRealm = $modifier->getRequiredRealm();
Avoid excessively long variable names like $modifiersDifficultyChangeSum. Keep variable name length under 20.
$modifiersDifficultyChangeSum = 0;
There are no issues that match your filters.