| Conditions | 11 |
| Paths | 12 |
| Total Lines | 47 |
| Code Lines | 31 |
| 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 |
||
| 35 | public function showAction($id, Request $request) |
||
| 36 | { |
||
| 37 | if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) { |
||
| 38 | throw $this->createAccessDeniedException(); |
||
| 39 | } |
||
| 40 | $em = $this->getDoctrine()->getManager(); |
||
| 41 | $client = $em->find('ClientBundle:Client', $id); |
||
| 42 | |||
| 43 | if (!$client) { |
||
| 44 | throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $id)); |
||
| 45 | } else { |
||
| 46 | $form = $this->createForm(ClientForm::class, $client, ['id' => $client->getId()]); |
||
| 47 | // перенести в вьюв |
||
| 48 | if ($this->isGranted('ROLE_ADMIN')) { |
||
| 49 | $form->add('delete', SubmitType::class); |
||
| 50 | } |
||
| 51 | |||
| 52 | $form->handleRequest($request); |
||
| 53 | |||
| 54 | if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) { |
||
| 55 | $client = $form->getData(); |
||
| 56 | |||
| 57 | if ($this->isGranted('ROLE_ADMIN') && $form->get('delete')->isClicked()) { |
||
|
|
|||
| 58 | return $this->redirectToRoute('client_del', ['id' => $client->getId()]); |
||
| 59 | } elseif ($form->get('addcontact')->isClicked()) { |
||
| 60 | $contact = new Contact(); |
||
| 61 | $clientForm = $request->request->get('client_form'); |
||
| 62 | |||
| 63 | $contactType = $em->find('ClientBundle:ContactType', $clientForm['newtypecontact']); |
||
| 64 | if (!$contactType) { |
||
| 65 | throw $this->createNotFoundException(sprintf('не знайдений об\'єкт з id : %s', $clientForm['newtypecontact'])); |
||
| 66 | } else { |
||
| 67 | $contact->setType($contactType); |
||
| 68 | $contact->setMean($clientForm['newmeancontact']); |
||
| 69 | $client->addContact($contact); |
||
| 70 | $em->persist($contact); |
||
| 71 | } |
||
| 72 | } else { |
||
| 73 | $em->flush(); |
||
| 74 | |||
| 75 | return $this->redirectToRoute('client_home'); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | return $this->render('ClientBundle:Default:edit.html.twig', ['form' => $form->createView(), 'client' => $client]); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 181 |
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.