Conditions | 13 |
Paths | 56 |
Total Lines | 54 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
75 | public function processWizard(Request $request, string $stage, $mode = 'install', YamlDumper $yamlDumper = null): Response |
||
76 | { |
||
77 | if (!in_array($mode, ['install', 'upgrade'])) { |
||
78 | $mode = 'install'; |
||
79 | } |
||
80 | |||
81 | $session = $request->hasSession() ? $request->getSession() : null; |
||
82 | |||
83 | // check php |
||
84 | $iniWarnings = $this->initPhp(); |
||
|
|||
85 | if (null !== $session && 0 < count($iniWarnings)) { |
||
86 | $session->getFlashBag()->add('warning', implode('<hr />', $iniWarnings)); |
||
87 | } |
||
88 | |||
89 | // begin the wizard |
||
90 | $wizard = new Wizard($this->stageContainer, dirname(__DIR__) . '/Resources/config/' . $mode . '_stages.yaml'); |
||
91 | $currentStage = $wizard->getCurrentStage($stage); |
||
92 | if ($currentStage instanceof WizardCompleteInterface) { |
||
93 | if ('upgrade' === $mode && null !== $yamlDumper) { |
||
94 | $yamlDumper->setParameter('upgrading', false); |
||
95 | } |
||
96 | |||
97 | return $currentStage->getResponse($request); |
||
98 | } |
||
99 | |||
100 | $templateParams = $this->getTemplateGlobals($currentStage); |
||
101 | $templateParams['headertemplate'] = '@ZikulaCoreInstaller/' . $mode . 'Header.html.twig'; |
||
102 | if ($wizard->isHalted()) { |
||
103 | if (null !== $session) { |
||
104 | $session->getFlashBag()->add('danger', $wizard->getWarning()); |
||
105 | } |
||
106 | |||
107 | return $this->renderResponse('@ZikulaCoreInstaller/error.html.twig', $templateParams); |
||
108 | } |
||
109 | |||
110 | // handle the form |
||
111 | if ($currentStage instanceof FormHandlerInterface) { |
||
112 | $form = $this->formFactory->create($currentStage->getFormType(), null, $currentStage->getFormOptions()); |
||
113 | $form->handleRequest($request); |
||
114 | if ($form->isSubmitted() && $form->isValid()) { |
||
115 | $currentStage->handleFormResult($form); |
||
116 | $params = [ |
||
117 | 'stage' => $wizard->getNextStage()->getName(), |
||
118 | '_locale' => $this->locale |
||
119 | ]; |
||
120 | |||
121 | $url = $this->router->generate($mode, $params); |
||
122 | |||
123 | return new RedirectResponse($url); |
||
124 | } |
||
125 | $templateParams['form'] = $form->createView(); |
||
126 | } |
||
127 | |||
128 | return $this->renderResponse($currentStage->getTemplateName(), $templateParams); |
||
129 | } |
||
151 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.