Conditions | 10 |
Paths | 142 |
Total Lines | 74 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
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 |
||
55 | public function export(Request $request, EntityManagerInterface $entityManager) |
||
56 | { |
||
57 | $this->denyAccessUnlessGranted('ROLE_EXPORT_PAYMENT_ORDERS'); |
||
58 | |||
59 | $ids = $request->query->get('ids'); |
||
60 | $id_array = explode(',', $ids); |
||
61 | //Retrieve all payment orders which should be retrieved from DB: |
||
62 | $payment_orders = []; |
||
63 | foreach ($id_array as $id) { |
||
64 | $payment_orders[] = $entityManager->find(PaymentOrder::class, $id); |
||
65 | } |
||
66 | |||
67 | $form = $this->createForm(SepaExportType::class); |
||
68 | |||
69 | $form->handleRequest($request); |
||
70 | |||
71 | if ($form->isSubmitted() && $form->isValid()) { |
||
72 | //Determine the Values to use |
||
73 | $data = $form->getData(); |
||
74 | //If user has selected a bank account preset, then use the data from it |
||
75 | if ($data['bank_account'] instanceof BankAccount) { |
||
76 | $iban = $data['bank_account']->getIban(); |
||
77 | $bic = $data['bank_account']->getBic(); |
||
78 | $name = $data['bank_account']->getExportAccountName(); |
||
79 | } else { //Use the manual inputted data |
||
80 | $iban = $data['iban']; |
||
81 | $bic = $data['bic']; |
||
82 | $name = $data['name']; |
||
83 | } |
||
84 | |||
85 | try { |
||
86 | //Call function depending on the selected mode |
||
87 | switch($data['mode']) { |
||
88 | case 'auto': |
||
89 | $result = $this->sepaExporter->exportAuto($payment_orders); |
||
90 | break; |
||
91 | case 'auto_single': |
||
92 | $result = $this->sepaExporter->exportAutoSingle($payment_orders); |
||
93 | break; |
||
94 | case 'manual': |
||
95 | $result = new SEPAXMLExportResult( |
||
96 | [ |
||
97 | $this->sepaExporter->exportUsingGivenIBAN($payment_orders, $iban, $bic, $name) |
||
98 | ] |
||
99 | ); |
||
100 | break; |
||
101 | default: |
||
102 | throw new \RuntimeException('Unknown mode!'); |
||
103 | } |
||
104 | |||
105 | //Set exported flag for each payment order |
||
106 | foreach ($payment_orders as $paymentOrder) { |
||
107 | $paymentOrder->setExported(true); |
||
108 | } |
||
109 | |||
110 | //Persist the SEPA exports to database |
||
111 | $result->persistSEPAExports($this->entityManager); |
||
112 | |||
113 | $this->entityManager->flush(); |
||
114 | |||
115 | //Return the download |
||
116 | return $result->getDownloadResponse('export_'.date('Y-m-d_H-i-s')); |
||
117 | |||
118 | } catch (SEPAExportAutoModeNotPossible $exception) { |
||
119 | //Show error if auto mode is not possible |
||
120 | $this->addFlash('danger', |
||
121 | $this->translator->trans('sepa_export.error.department_missing_account') |
||
122 | .': '.$exception->getWrongDepartment()->getName()); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | return $this->render('admin/payment_order/export/export.html.twig', [ |
||
127 | 'payment_orders' => $payment_orders, |
||
128 | 'form' => $form->createView(), |
||
129 | ]); |
||
132 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths