| Conditions | 14 |
| Paths | 10 |
| Total Lines | 60 |
| 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 |
||
| 17 | public function before(Arguments $arguments) |
||
| 18 | { |
||
| 19 | $request = $this->getRequest(); |
||
| 20 | |||
| 21 | if (!$request->hasArgument('skip') |
||
| 22 | || !$request->getArgument('skip') |
||
| 23 | ) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | |||
| 27 | $formName = $this->getFormObject()->getName(); |
||
| 28 | |||
| 29 | if (!$request->hasArgument($formName)) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (!$request->hasArgument('step')) { |
||
| 34 | return; |
||
| 35 | } |
||
| 36 | |||
| 37 | $step = $request->getArgument('step'); |
||
| 38 | $definition = $this->getFormObject()->getDefinition(); |
||
| 39 | |||
| 40 | if (!$definition->hasSteps() |
||
| 41 | || !$definition->getSteps()->hasEntry($step) |
||
| 42 | ) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | |||
| 46 | $currentStep = $definition->getSteps()->getEntry($step); |
||
| 47 | |||
| 48 | /** @var array $formArray */ |
||
| 49 | $formArray = $request->getArgument($formName); |
||
| 50 | |||
| 51 | $skipSubsteps = []; |
||
| 52 | |||
| 53 | if ($request->hasArgument('skipSubsteps')) { |
||
| 54 | $skipSubsteps = GeneralUtility::trimExplode(',', $request->getArgument('skipSubsteps')); |
||
| 55 | } |
||
| 56 | |||
| 57 | if (empty($skipSubsteps)) { |
||
| 58 | foreach ($currentStep->getSupportedFields() as $field) { |
||
| 59 | unset($formArray[$field->getField()->getName()]); |
||
| 60 | } |
||
| 61 | } elseif ($currentStep->hasSubsteps()) { |
||
| 62 | $substeps = $currentStep->getSubsteps(); |
||
| 63 | |||
| 64 | foreach ($skipSubsteps as $substep) { |
||
| 65 | if (!$substeps->hasEntry($substep)) { |
||
| 66 | continue; |
||
| 67 | } |
||
| 68 | |||
| 69 | foreach ($substeps->getEntry($substep)->getSupportedFields() as $field) { |
||
| 70 | unset($formArray[$field->getField()->getName()]); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 75 | $request->setArgument($formName, $formArray); |
||
| 76 | } |
||
| 77 | } |
||
| 78 |