Conditions | 7 |
Paths | 12 |
Total Lines | 52 |
Lines | 19 |
Ratio | 36.54 % |
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 |
||
32 | public function institutionConfigurationAction(Request $request) |
||
33 | { |
||
34 | $this->denyAccessUnlessGranted(['ROLE_RAA', 'ROLE_SRAA']); |
||
35 | |||
36 | $logger = $this->get('logger'); |
||
37 | /** @var Identity $identity */ |
||
38 | $identity = $this->getUser(); |
||
39 | |||
40 | $profile = $this->getProfileService()->findByIdentityId($identity->id); |
||
41 | |||
42 | View Code Duplication | if ($this->isGranted('ROLE_SRAA')) { |
|
43 | $institution = $identity->institution; |
||
44 | $choices = $this->getInstitutionListingService()->getAll(); |
||
45 | } else { |
||
46 | $choices = $profile->getRaaInstitutions(); |
||
47 | $institution = reset($choices); |
||
48 | } |
||
49 | |||
50 | // Only show the form if more than one institutions where found. |
||
51 | View Code Duplication | if (count($choices) > 1) { |
|
52 | $command = new SelectInstitutionCommand(); |
||
53 | $command->institution = $institution; |
||
54 | $command->availableInstitutions = $choices; |
||
55 | |||
56 | $form = $this->createForm(SelectInstitutionType::class, $command); |
||
57 | $form->handleRequest($request); |
||
58 | |||
59 | if ($form->isSubmitted() && $form->isValid()) { |
||
60 | $institution = $command->institution; |
||
61 | } |
||
62 | } |
||
63 | |||
64 | $logger->notice(sprintf('Opening the institution configuration for "%s"', $institution)); |
||
65 | |||
66 | // Load the configuration for the institution that was selected. |
||
67 | $configuration = $this->getInstitutionConfigurationOptionsService() |
||
68 | ->getInstitutionConfigurationOptionsFor($institution); |
||
69 | |||
70 | if (!$configuration) { |
||
71 | $logger->warning(sprintf('Unable to find the institution configuration for "%s"', $institution)); |
||
72 | return $this->createNotFoundException('The institution configuration could not be found'); |
||
73 | } |
||
74 | |||
75 | return $this->render( |
||
76 | '@SurfnetStepupRaRa/institution_configuration/overview.html.twig', |
||
77 | [ |
||
78 | 'configuration' => (array)$configuration, |
||
79 | 'form' => isset($form) ? $form->createView() : null, |
||
80 | 'institution' => $institution, |
||
81 | ] |
||
82 | ); |
||
83 | } |
||
84 | |||
109 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.