| Conditions | 2 |
| Paths | 2 |
| Total Lines | 60 |
| Code Lines | 10 |
| 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 |
||
| 44 | public function indexAction(Request $request): Response |
||
| 45 | { |
||
| 46 | /** @var \PageController $pageController */ |
||
| 47 | //$pageController = $this->get('page_controller'); |
||
| 48 | $pageController = new PageController(); |
||
| 49 | |||
| 50 | //$sessionHandler = $request->getSession(); |
||
| 51 | //$sessionHandler->remove('coursesAlreadyVisited'); |
||
| 52 | |||
| 53 | $user = $this->getUser(); |
||
| 54 | $userId = 0; |
||
| 55 | if ($user) { |
||
| 56 | $userId = $this->getUser()->getId(); |
||
| 57 | } |
||
| 58 | $announcementsBlock = $pageController->getAnnouncements($userId); |
||
| 59 | |||
| 60 | /** @var User $user */ |
||
| 61 | //$userManager = $this->container->get('fos_user.user_manager'); |
||
| 62 | //$user = $userManager->find(1); |
||
| 63 | |||
| 64 | //$attribute = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:ExtraField')->find(1); |
||
| 65 | /* |
||
| 66 | $attribute = new ExtraField(); |
||
| 67 | $attribute->setName('size'); |
||
| 68 | $attribute->setVariable('size'); |
||
| 69 | $attribute->setType(TextAttributeType::TYPE); |
||
| 70 | $attribute->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 71 | $this->getDoctrine()->getManager()->persist($attribute); |
||
| 72 | $this->getDoctrine()->getManager()->flush(); |
||
| 73 | |||
| 74 | $attributeColor = new ExtraField(); |
||
| 75 | $attributeColor->setName('color'); |
||
| 76 | $attributeColor->setVariable('color'); |
||
| 77 | $attributeColor->setType(TextAttributeType::TYPE); |
||
| 78 | $attributeColor->setStorageType(AttributeValueInterface::STORAGE_TEXT); |
||
| 79 | $this->getDoctrine()->getManager()->persist($attributeColor); |
||
| 80 | $this->getDoctrine()->getManager()->flush(); |
||
| 81 | |||
| 82 | $color = new ExtraFieldValues(); |
||
| 83 | $color->setComment('lol'); |
||
| 84 | $color->setAttribute($attributeColor); |
||
| 85 | $color->setValue('blue'); |
||
| 86 | |||
| 87 | $user->addAttribute($color); |
||
| 88 | |||
| 89 | $smallSize = new ExtraFieldValues(); |
||
| 90 | $smallSize->setComment('lol'); |
||
| 91 | $smallSize->setAttribute($attribute); |
||
| 92 | $smallSize->setValue('S'); |
||
| 93 | |||
| 94 | $user->addAttribute($smallSize); |
||
| 95 | $userManager->updateUser($user); |
||
| 96 | */ |
||
| 97 | //$this->get('session')->remove('id_session'); |
||
| 98 | |||
| 99 | return $this->render( |
||
| 100 | '@ChamiloCore/Index/index.html.twig', |
||
| 101 | [ |
||
| 102 | 'content' => '', |
||
| 103 | 'announcements_block' => $announcementsBlock, |
||
| 104 | //'home_page_block' => $pageController->returnHomePage() |
||
| 137 |