| Conditions | 11 |
| Paths | 40 |
| Total Lines | 48 |
| Code Lines | 27 |
| 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 |
||
| 36 | public function installAction(Request $request, string $stage): Response |
||
| 37 | { |
||
| 38 | // already installed? |
||
| 39 | if ('complete' !== $stage && true === $this->container->getParameter('installed')) { |
||
| 40 | $stage = 'installed'; |
||
| 41 | } |
||
| 42 | |||
| 43 | // not installed but requesting installed stage? |
||
| 44 | if ('installed' === $stage && false === $this->container->getParameter('installed')) { |
||
| 45 | $stage = 'notinstalled'; |
||
| 46 | } |
||
| 47 | |||
| 48 | // check php |
||
| 49 | $ini_warnings = $this->controllerHelper->initPhp(); |
||
| 50 | if (count($ini_warnings) > 0) { |
||
| 51 | $request->getSession()->getFlashBag()->add('warning', implode('<hr>', $ini_warnings)); |
||
| 52 | } |
||
| 53 | |||
| 54 | $request->setLocale($this->container->getParameter('locale')); |
||
| 55 | // begin the wizard |
||
| 56 | $wizard = new Wizard($this->container, dirname(__DIR__) . '/Resources/config/install_stages.yml'); |
||
| 57 | $currentStage = $wizard->getCurrentStage($stage); |
||
| 58 | if ($currentStage instanceof WizardCompleteInterface) { |
||
| 59 | return $currentStage->getResponse($request); |
||
| 60 | } |
||
| 61 | $templateParams = $this->controllerHelper->getTemplateGlobals($currentStage); |
||
| 62 | $templateParams['headertemplate'] = '@ZikulaCoreInstaller/installheader.html.twig'; |
||
| 63 | if ($wizard->isHalted()) { |
||
| 64 | $request->getSession()->getFlashBag()->add('danger', $wizard->getWarning()); |
||
| 65 | |||
| 66 | return $this->renderResponse('@ZikulaCoreInstaller/error.html.twig', $templateParams); |
||
| 67 | } |
||
| 68 | |||
| 69 | // handle the form |
||
| 70 | if ($currentStage instanceof FormHandlerInterface) { |
||
| 71 | $form = $this->form->create($currentStage->getFormType(), null, $currentStage->getFormOptions()); |
||
|
|
|||
| 72 | $form->handleRequest($request); |
||
| 73 | if ($form->isSubmitted() && $form->isValid()) { |
||
| 74 | $currentStage->handleFormResult($form); |
||
| 75 | $params = ['stage' => $wizard->getNextStage()->getName(), '_locale' => $this->container->getParameter('locale')]; |
||
| 76 | $url = $this->router->generate('install', $params); |
||
| 77 | |||
| 78 | return new RedirectResponse($url); |
||
| 79 | } |
||
| 80 | $templateParams['form'] = $form->createView(); |
||
| 81 | } |
||
| 82 | |||
| 83 | return $this->renderResponse($currentStage->getTemplateName(), $templateParams); |
||
| 84 | } |
||
| 86 |
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.