| Conditions | 10 |
| Paths | 15 |
| Total Lines | 44 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 74 | protected function getCurrentSubstepDefinition() |
||
| 75 | { |
||
| 76 | $stepService = FormObjectFactory::get()->getStepService($this->getFormObject()); |
||
| 77 | |||
| 78 | $firstSubstepDefinition = $this->dataObject->getValidatedStep()->getSubsteps()->getFirstSubstepDefinition(); |
||
| 79 | $currentSubstepDefinition = $firstSubstepDefinition; |
||
| 80 | $substepDefinition = $firstSubstepDefinition; |
||
| 81 | $substepsLevel = $stepService->getSubstepsLevel(); |
||
| 82 | |||
| 83 | while ($this->dataObject->isDummyMode() || $substepsLevel > 0) { |
||
| 84 | $substepsLevel--; |
||
| 85 | $substepIsActivated = true; |
||
| 86 | |||
| 87 | if ($substepDefinition->hasActivation()) { |
||
| 88 | $substepIsActivated = $this->getSubstepDefinitionActivationResult($substepDefinition); |
||
| 89 | } |
||
| 90 | |||
| 91 | if (true === $substepIsActivated) { |
||
| 92 | $supportedFields = $substepDefinition->getSubstep()->getSupportedFields(); |
||
| 93 | |||
| 94 | foreach ($supportedFields as $supportedField) { |
||
| 95 | $this->formValidatorExecutor->validateField($supportedField->getField()); |
||
| 96 | } |
||
| 97 | |||
| 98 | if ($this->getResult()->hasErrors()) { |
||
| 99 | $currentSubstepDefinition = $substepDefinition; |
||
| 100 | break; |
||
| 101 | } |
||
| 102 | } |
||
| 103 | |||
| 104 | if (!$this->dataObject->isDummyMode() && $substepsLevel === 0) { |
||
| 105 | $currentSubstepDefinition = $substepDefinition; |
||
| 106 | break; |
||
| 107 | } |
||
| 108 | |||
| 109 | if (false === $substepDefinition->hasNextSubstep()) { |
||
| 110 | break; |
||
| 111 | } |
||
| 112 | |||
| 113 | $substepDefinition = $substepDefinition->getNextSubstep(); |
||
| 114 | } |
||
| 115 | |||
| 116 | return $currentSubstepDefinition; |
||
| 117 | } |
||
| 118 | |||
| 175 |