| Conditions | 8 |
| Paths | 8 |
| Total Lines | 54 |
| Code Lines | 29 |
| 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 |
||
| 61 | public function execute($request): void |
||
| 62 | { |
||
| 63 | RequestNotSupportedException::assertSupports($this, $request); |
||
| 64 | |||
| 65 | $details = ArrayObject::ensureArrayObject($request->getModel()); |
||
| 66 | $this->gateway->execute($this->getHttpRequest); |
||
| 67 | |||
| 68 | if (true === isset($details['payment_mollie_id'])) { |
||
| 69 | try { |
||
| 70 | $payment = $this->mollieApiClient->payments->get($this->getHttpRequest->request['id']); |
||
| 71 | } catch (\Exception $e) { |
||
| 72 | $this->loggerAction->addNegativeLog(sprintf('Error with get customer from mollie with: %s', $e->getMessage())); |
||
| 73 | |||
| 74 | throw new ApiException(sprintf('Error with get customer from mollie with: %s', $e->getMessage())); |
||
| 75 | } |
||
| 76 | |||
| 77 | if ($details['metadata']['order_id'] === filter_var($payment->metadata->order_id, \FILTER_VALIDATE_INT)) { |
||
| 78 | $details['payment_mollie_id'] = $this->getHttpRequest->request['id']; |
||
| 79 | } |
||
| 80 | |||
| 81 | $this->loggerAction->addLog(sprintf('Notify payment with id: %s', $payment->id)); |
||
| 82 | |||
| 83 | throw new HttpResponse(Response::$statusTexts[Response::HTTP_OK], Response::HTTP_OK); |
||
| 84 | } |
||
| 85 | |||
| 86 | if (true === isset($details['subscription_mollie_id'])) { |
||
| 87 | /** @var SubscriptionInterface $subscription */ |
||
| 88 | $subscription = $this->subscriptionRepository->findOneByOrderId($details['metadata']['order_id']); |
||
| 89 | |||
| 90 | $this->gateway->execute(new StatusRecurringSubscription($subscription)); |
||
| 91 | |||
| 92 | $this->loggerAction->addLog(sprintf('Notify subscription with id: %s', $details['subscription_mollie_id'])); |
||
| 93 | |||
| 94 | throw new HttpResponse(Response::$statusTexts[Response::HTTP_OK], Response::HTTP_OK); |
||
| 95 | } |
||
| 96 | |||
| 97 | if (true === isset($details['order_mollie_id'])) { |
||
| 98 | try { |
||
| 99 | $order = $this->mollieApiClient->orders->get($this->getHttpRequest->request['id']); |
||
| 100 | } catch (\Exception $e) { |
||
| 101 | $this->loggerAction->addNegativeLog(sprintf('Error with get order from mollie with: %s', $e->getMessage())); |
||
| 102 | |||
| 103 | throw new ApiException('Error to get order with ' . $e->getMessage()); |
||
| 104 | } |
||
| 105 | |||
| 106 | if ($details['metadata']['order_id'] === filter_var($order->metadata->order_id, \FILTER_VALIDATE_INT)) { |
||
| 107 | $details['order_mollie_id'] = $this->getHttpRequest->request['id']; |
||
| 108 | } |
||
| 109 | |||
| 110 | $this->setStatusOrderAction->execute($order); |
||
| 111 | |||
| 112 | $this->loggerAction->addLog(sprintf('Notify order with id: %s', $order->id)); |
||
| 113 | |||
| 114 | throw new HttpResponse(Response::$statusTexts[Response::HTTP_OK], Response::HTTP_OK); |
||
| 115 | } |
||
| 126 |