Conditions | 15 |
Paths | 264 |
Total Lines | 84 |
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 |
||
121 | public function createAction() |
||
122 | { |
||
123 | // Check current user authorization |
||
124 | if (null !== $response = $this->checkAuth(self::CONTROLLER_CHECK_RESOURCE, Dealer::getModuleCode(), |
||
125 | AccessManager::CREATE) |
||
126 | ) { |
||
127 | return $response; |
||
128 | } |
||
129 | |||
130 | // Create the Creation Form |
||
131 | $creationForm = $this->getCreationForm($this->getRequest()); |
||
132 | |||
133 | $con = Propel::getConnection(); |
||
134 | $con->beginTransaction(); |
||
135 | |||
136 | try { |
||
137 | // Check the form against constraints violations |
||
138 | $form = $this->validateForm($creationForm, "POST"); |
||
139 | // Get the form field values |
||
140 | $data = $form->getData(); |
||
141 | |||
142 | if (empty($data["day"])) { |
||
143 | $dataAM = $this->formatData($data); |
||
144 | $dataPM = $this->formatData($data, 'PM'); |
||
145 | |||
146 | if ($this->hasNullDate($dataAM) && $this->hasNullDate($dataPM)) { |
||
147 | $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale()); |
||
148 | } else { |
||
149 | if (!$this->hasNullDate($dataAM)) { |
||
150 | $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale()); |
||
151 | } |
||
152 | if (!$this->hasNullDate($dataPM)) { |
||
153 | $this->getService()->createFromArray($dataPM, $this->getCurrentEditionLocale()); |
||
154 | } |
||
155 | } |
||
156 | } else { |
||
157 | foreach ($data["day"] as $day) { |
||
158 | $currentData = $data; |
||
159 | $currentData["day"] = $day; |
||
160 | $dataAM = $this->formatData($currentData); |
||
161 | $dataPM = $this->formatData($currentData, 'PM'); |
||
162 | |||
163 | if ($this->hasNullDate($dataAM) && $this->hasNullDate($dataPM)) { |
||
164 | $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale()); |
||
165 | } else { |
||
166 | if (!$this->hasNullDate($dataAM)) { |
||
167 | $this->getService()->createFromArray($dataAM, $this->getCurrentEditionLocale()); |
||
168 | } |
||
169 | if (!$this->hasNullDate($dataPM)) { |
||
170 | $this->getService()->createFromArray($dataPM, $this->getCurrentEditionLocale()); |
||
171 | } |
||
172 | } |
||
173 | } |
||
174 | } |
||
175 | |||
176 | |||
177 | // Substitute _ID_ in the URL with the ID of the created object |
||
178 | $successUrl = $creationForm->getSuccessUrl(); |
||
179 | |||
180 | $con->commit(); |
||
181 | |||
182 | // Redirect to the success URL |
||
183 | return $this->generateRedirect($successUrl); |
||
184 | } catch (FormValidationException $ex) { |
||
|
|||
185 | $con->rollBack(); |
||
186 | // Form cannot be validated |
||
187 | $error_msg = $this->createStandardFormValidationErrorMessage($ex); |
||
188 | } catch (\Exception $ex) { |
||
189 | $con->rollBack(); |
||
190 | // Any other error |
||
191 | $error_msg = $ex->getMessage(); |
||
192 | } |
||
193 | if (false !== $error_msg) { |
||
194 | $this->setupFormErrorContext( |
||
195 | $this->getTranslator()->trans("%obj creation", ['%obj' => static::CONTROLLER_ENTITY_NAME]), |
||
196 | $error_msg, |
||
197 | $creationForm, |
||
198 | $ex |
||
199 | ); |
||
200 | |||
201 | // At this point, the form has error, and should be redisplayed. |
||
202 | return $this->generateErrorRedirect($creationForm); |
||
203 | } |
||
204 | } |
||
205 | |||
290 |
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.