| Conditions | 4 |
| Paths | 4 |
| Total Lines | 64 |
| Code Lines | 35 |
| 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 |
||
| 23 | public function registerAction(Request $request) |
||
| 24 | { |
||
| 25 | /** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */ |
||
| 26 | $formFactory = $this->get('fos_user.registration.form.factory'); |
||
| 27 | /** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */ |
||
| 28 | $userManager = $this->get('fos_user.user_manager'); |
||
| 29 | /** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */ |
||
| 30 | $dispatcher = $this->get('event_dispatcher'); |
||
| 31 | |||
| 32 | /** @var User $user */ |
||
| 33 | $user = $userManager->createUser(); |
||
| 34 | $user->setEnabled(true); |
||
| 35 | |||
| 36 | $event = new GetResponseUserEvent($user, $request); |
||
| 37 | $dispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event); |
||
| 38 | |||
| 39 | if (null !== $event->getResponse()) { |
||
| 40 | return $event->getResponse(); |
||
| 41 | } |
||
| 42 | |||
| 43 | $form = $formFactory->createForm(); |
||
| 44 | $form->setData($user); |
||
| 45 | |||
| 46 | $userService = $this->get('kingdom.user_service'); |
||
| 47 | |||
| 48 | $form->handleRequest($request); |
||
| 49 | $this->updateUserAndForm($user, $form, $userService); |
||
| 50 | |||
| 51 | if ($form->isValid()) { |
||
| 52 | $event = new FormEvent($form, $request); |
||
| 53 | $dispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event); |
||
| 54 | |||
| 55 | $user->setAvatar($userService->pickAvatar()); |
||
| 56 | $user->setRoom($userService->getStartRoom()); |
||
| 57 | |||
| 58 | $userManager->updateUser($user); |
||
| 59 | |||
| 60 | if (null === $response = $event->getResponse()) { |
||
|
|
|||
| 61 | $url = $this->generateUrl('game_page'); |
||
| 62 | $response = new RedirectResponse($url); |
||
| 63 | } |
||
| 64 | |||
| 65 | $dispatcher->dispatch( |
||
| 66 | FOSUserEvents::REGISTRATION_COMPLETED, |
||
| 67 | new FilterUserResponseEvent($user, $request, $response) |
||
| 68 | ); |
||
| 69 | |||
| 70 | $this->createMoney($user); |
||
| 71 | $userService->giveStarterItems($user); |
||
| 72 | |||
| 73 | /** @var RegistrationLogger $logger */ |
||
| 74 | $logger = $this->container->get('user.logger.registration'); |
||
| 75 | $logger->logRegistration($user); |
||
| 76 | |||
| 77 | return $response; |
||
| 78 | } |
||
| 79 | |||
| 80 | return $this->render( |
||
| 81 | 'FOSUserBundle:Registration:register.html.twig', |
||
| 82 | [ |
||
| 83 | 'form' => $form->createView(), |
||
| 84 | ] |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 122 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.