Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 23, 2024
1 parent eaf3f4f commit e427c05
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
23 changes: 13 additions & 10 deletions inc/api/order-functions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


/**
* The API for operations with orders.
*
Expand All @@ -14,9 +13,7 @@
namespace Mollie\WooCommerce\Inc\Api;

use Mollie\WooCommerce\PluginApi\MolliePluginApi;
use \WC_Order;


use WC_Order;

/**
* Captures the Mollie order.
Expand All @@ -25,7 +22,9 @@
* @param WC_Order $wc_order The WC order.
*
*/
function mollie_capture_order(WC_Order $wc_order): void {
function mollie_capture_order(WC_Order $wc_order): void
{

$mollieApi = MolliePluginApi::getInstance();
$mollieApi->captureOrder($wc_order);
}
Expand All @@ -38,7 +37,9 @@ function mollie_capture_order(WC_Order $wc_order): void {
* @param string $reason The reason for the refund.
* @return \WP_Error|bool The result of the refund operation.
*/
function mollie_refund_order(WC_Order $wc_order, float $amount, string $reason = '') {
function mollie_refund_order(WC_Order $wc_order, float $amount, string $reason = '')
{

$mollieApi = MolliePluginApi::getInstance();
return $mollieApi->refundOrder($wc_order, $amount, $reason);
}
Expand All @@ -50,7 +51,9 @@ function mollie_refund_order(WC_Order $wc_order, float $amount, string $reason =
* @param WC_Order $wc_order The WC order.
*
*/
function mollie_void_order(WC_Order $wc_order): void {
function mollie_void_order(WC_Order $wc_order): void
{

$mollieApi = MolliePluginApi::getInstance();
$mollieApi->voidOrder($wc_order);
}
Expand All @@ -61,7 +64,9 @@ function mollie_void_order(WC_Order $wc_order): void {
*
* @param WC_Order $wc_order The WC order.
*/
function mollie_cancel_order(WC_Order $wc_order): void {
function mollie_cancel_order(WC_Order $wc_order): void
{

$order_id = $wc_order->get_id();
$mollieApi = MolliePluginApi::getInstance();
$mollieApi->cancelOrder((string)$order_id);
Expand All @@ -80,5 +85,3 @@ function mollie_ship_order(WC_Order $wc_order): void
$mollieApi = MolliePluginApi::getInstance();
$mollieApi->shipOrderAndCapture((string)$order_id);
}


1 change: 1 addition & 0 deletions src/Gateway/GatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ public function buildPaymentMethod(
Surcharge $surchargeService,
array $apiMethod
) {

$transformedId = ucfirst($id);
$paymentMethodClassName = 'Mollie\\WooCommerce\\PaymentMethods\\' . $transformedId;
$paymentMethod = new $paymentMethodClassName(
Expand Down
1 change: 0 additions & 1 deletion src/Payment/MollieObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ public function shipAndCaptureOrderAtMollie($order_id)
return;
}


public function getMolliePaymentIdFromPaymentObject()
{
}
Expand Down
28 changes: 20 additions & 8 deletions src/PluginApi/MolliePluginApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
use Closure;
use Mollie\WooCommerce\Payment\MollieObject;

class MolliePluginApi {
class MolliePluginApi
{
private static $instance = null;
private Closure $capturePayment;
private Closure $voidPayment;

private MollieObject $mollieObject;

private function __construct(
Closure $capturePayment,
Closure $voidPayment,
MollieObject $mollieObject
) {

$this->capturePayment = $capturePayment;
$this->voidPayment = $voidPayment;
$this->mollieObject = $mollieObject;
Expand All @@ -30,6 +31,7 @@ public static function init(
Closure $voidPayment,
MollieObject $mollieObject
): void {

if (self::$instance === null) {
self::$instance = new self(
$capturePayment,
Expand All @@ -44,7 +46,9 @@ public static function init(
*
* @throws \LogicException If the API has not been initialized.
*/
public static function getInstance(): self {
public static function getInstance(): self
{

if (self::$instance === null) {
throw new \LogicException('MolliePluginApi has not been initialized.');
}
Expand All @@ -57,7 +61,9 @@ public static function getInstance(): self {
*
* @param \WC_Order $wcOrder The WooCommerce order.
*/
public function captureOrder(\WC_Order $wcOrder): void {
public function captureOrder(\WC_Order $wcOrder): void
{

($this->capturePayment)($wcOrder->get_id());
}

Expand All @@ -69,8 +75,10 @@ public function captureOrder(\WC_Order $wcOrder): void {
* @param string $reason The reason for the refund.
* @return \WP_Error|bool The result of the refund operation.
*/
public function refundOrder(\WC_Order $wcOrder, float $amount, string $reason = '') {
return $this->mollieObject->processRefund($wcOrder->get_id(), $amount , $reason);
public function refundOrder(\WC_Order $wcOrder, float $amount, string $reason = '')
{

return $this->mollieObject->processRefund($wcOrder->get_id(), $amount, $reason);
}

/**
Expand All @@ -79,7 +87,9 @@ public function refundOrder(\WC_Order $wcOrder, float $amount, string $reason =
*
* @param \WC_Order $wcOrder The WooCommerce order.
*/
public function voidOrder(\WC_Order $wcOrder): void {
public function voidOrder(\WC_Order $wcOrder): void
{

($this->voidPayment)($wcOrder->get_id());
}

Expand All @@ -89,7 +99,9 @@ public function voidOrder(\WC_Order $wcOrder): void {
*
* @param \WC_Order $wcOrder The WooCommerce order.
*/
public function cancelOrder(string $orderId): void {
public function cancelOrder(string $orderId): void
{

$this->mollieObject->cancelOrderAtMollie($orderId);
}

Expand Down
4 changes: 3 additions & 1 deletion src/PluginApi/PluginApiModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class PluginApiModule implements ExecutableModule
{
use ModuleClassNameIdTrait;

public function run (ContainerInterface $container): bool {
public function run(ContainerInterface $container): bool
{

MolliePluginApi::init(
$container->get(CapturePayment::class),
$container->get(VoidPayment::class),
Expand Down

0 comments on commit e427c05

Please sign in to comment.