| Conditions | 3 |
| Paths | 2 |
| Total Lines | 35 |
| Code Lines | 21 |
| Lines | 35 |
| Ratio | 100 % |
| Tests | 20 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 1 | public function __invoke(Request $request) |
|
| 18 | { |
||
| 19 | // the Admin with auto injected with the KernelSubscriber |
||
| 20 | 1 | $this |
|
| 21 | ->admin |
||
| 22 | 1 | ->handleRequest($request) |
|
| 23 | ; |
||
| 24 | // create the configured form type |
||
| 25 | 1 | $formType = $this |
|
| 26 | ->configuration |
||
| 27 | 1 | ->getParameter('form') |
|
| 28 | 1 | ; |
|
| 29 | 1 | $formOptions = $this |
|
| 30 | ->configuration |
||
| 31 | 1 | ->getParameter('form_options') |
|
| 32 | 1 | ; |
|
| 33 | 1 | $form = $this |
|
| 34 | ->formFactory |
||
| 35 | 1 | ->create($formType, $this->admin->getUniqueEntity(), $formOptions) |
|
| 36 | 1 | ; |
|
| 37 | 1 | $form->handleRequest($request); |
|
| 38 | |||
| 39 | 1 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 40 | // remove the entity |
||
| 41 | 1 | $this |
|
| 42 | ->admin |
||
| 43 | 1 | ->remove() |
|
| 44 | ; |
||
| 45 | 1 | } |
|
| 46 | |||
| 47 | 1 | return $this |
|
| 48 | ->responder |
||
| 49 | 1 | ->respond($this->configuration, $this->admin, $form, $request) |
|
| 50 | 1 | ; |
|
| 51 | } |
||
| 52 | } |
||
| 53 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.