| Conditions | 5 |
| Paths | 1 |
| Total Lines | 57 |
| 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 |
||
| 38 | public function xmlAction(Request $request) |
||
| 39 | { |
||
| 40 | $em = $this->getDoctrine()->getManager(); |
||
| 41 | $homepage = $em->getRepository('VictoirePageBundle:BasePage') |
||
|
|
|||
| 42 | ->findOneByHomepage($request->getLocale()); |
||
| 43 | |||
| 44 | /** @var ViewReference $tree */ |
||
| 45 | $tree = $this->get('victoire_view_reference.repository')->getOneReferenceByParameters( |
||
| 46 | ['viewId' => $homepage->getId()], |
||
| 47 | true, |
||
| 48 | true |
||
| 49 | ); |
||
| 50 | |||
| 51 | $ids = [$tree->getViewId()]; |
||
| 52 | |||
| 53 | $getChildrenIds = function (ViewReference $tree) use (&$getChildrenIds, $ids) { |
||
| 54 | foreach ($tree->getChildren() as $child) { |
||
| 55 | $ids[] = $child->getViewId(); |
||
| 56 | $ids = array_merge($ids, $getChildrenIds($child)); |
||
| 57 | } |
||
| 58 | |||
| 59 | return $ids; |
||
| 60 | }; |
||
| 61 | |||
| 62 | $pages = $em->getRepository('VictoirePageBundle:BasePage') |
||
| 63 | ->getAll(true) |
||
| 64 | ->joinSeo() |
||
| 65 | ->filterByIds($getChildrenIds($tree)) |
||
| 66 | ->run(); |
||
| 67 | |||
| 68 | /** @var PageHelper $pageHelper */ |
||
| 69 | $pageHelper = $this->get('victoire_page.page_helper'); |
||
| 70 | $entityManager = $this->getDoctrine()->getManager(); |
||
| 71 | |||
| 72 | $getBusinessPages = function (ViewReference $tree) use (&$getBusinessPages, $pageHelper, $entityManager) { |
||
| 73 | $businessPages = []; |
||
| 74 | foreach ($tree->getChildren() as $child) { |
||
| 75 | if ($child instanceof BusinessPageReference |
||
| 76 | && $child->getViewNamespace() == 'Victoire\Bundle\BusinessPageBundle\Entity\VirtualBusinessPage') { |
||
| 77 | $entity = $entityManager->getRepository($child->getEntityNamespace())->find($child->getEntityId()); |
||
| 78 | /** @var WebViewInterface $businessPage */ |
||
| 79 | $businessPage = $pageHelper->findPageByReference($child, $entity); |
||
| 80 | $businessPage->setReference($child); |
||
| 81 | $businessPages[] = $businessPage; |
||
| 82 | } |
||
| 83 | $businessPages = array_merge($businessPages, $getBusinessPages($child)); |
||
| 84 | } |
||
| 85 | |||
| 86 | return $businessPages; |
||
| 87 | }; |
||
| 88 | |||
| 89 | $pages = array_merge($pages, $getBusinessPages($tree)); |
||
| 90 | |||
| 91 | return $this->render('VictoireSitemapBundle:Sitemap:sitemap.xml.twig', [ |
||
| 92 | 'pages' => $pages, |
||
| 93 | ]); |
||
| 94 | } |
||
| 95 | |||
| 217 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.