| @@ -10,9 +10,8 @@ | ||
| 10 | 10 | namespace Packetery\Module\Order; |
| 11 | 11 | |
| 12 | 12 | use Packetery\Module\Options\OptionsProvider; |
| 13 | 13 | use Packetery\Module\PaymentGatewayHelper; |
| 14 | -use Packetery\Module\WcLogger; | |
| 15 | 14 | use WC_Payment_Gateway; |
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * Class PacketAutoSubmitter |
| @@ -81,15 +80,9 @@ | ||
| 81 | 80 | foreach ( $mappedEvents as $mappedEvent ) { |
| 82 | 81 | if ( $mappedEvent === self::EVENT_ON_ORDER_COMPLETED ) { |
| 83 | 82 | add_action( |
| 84 | 83 | 'woocommerce_order_status_completed', |
| 85 | - function ( $orderId ): void { | |
| 86 | - if ( ! is_int( $orderId ) ) { | |
| 87 | - WcLogger::logArgumentTypeError( __METHOD__, 'orderId', 'int', $orderId ); | |
| 88 | - | |
| 89 | - return; | |
| 90 | - } | |
| 91 | - | |
| 84 | + function ( int $orderId ): void { | |
| 92 | 85 | $this->handleEvent( self::EVENT_ON_ORDER_COMPLETED, $orderId ); |
| 93 | 86 | } |
| 94 | 87 | ); |
| 95 | 88 | |
| @@ -98,15 +91,9 @@ | ||
| 98 | 91 | |
| 99 | 92 | if ( $mappedEvent === self::EVENT_ON_ORDER_PROCESSING ) { |
| 100 | 93 | add_action( |
| 101 | 94 | 'woocommerce_order_status_processing', |
| 102 | - function ( $orderId ): void { | |
| 103 | - if ( ! is_int( $orderId ) ) { | |
| 104 | - WcLogger::logArgumentTypeError( __METHOD__, 'orderId', 'int', $orderId ); | |
| 105 | - | |
| 106 | - return; | |
| 107 | - } | |
| 108 | - | |
| 95 | + function ( int $orderId ): void { | |
| 109 | 96 | $this->handleEvent( self::EVENT_ON_ORDER_PROCESSING, $orderId ); |
| 110 | 97 | } |
| 111 | 98 | ); |
| 112 | 99 | } |
| @@ -115,26 +102,15 @@ | ||
| 115 | 102 | |
| 116 | 103 | /** |
| 117 | 104 | * Handle event. |
| 118 | 105 | * |
| 119 | - * @param string|mixed $event Event. | |
| 120 | - * @param int|mixed $orderId WC Order. | |
| 106 | + * @param string $event Event. | |
| 107 | + * @param int $orderId WC Order. | |
| 108 | + * | |
| 121 | 109 | * @return void |
| 122 | 110 | */ |
| 123 | - public function handleEvent( $event, $orderId ): void { | |
| 111 | + public function handleEvent( string $event, int $orderId ): void { | |
| 124 | 112 | if ( $this->optionsProvider->isPacketAutoSubmissionEnabled() === false ) { |
| 125 | - return; | |
| 126 | - } | |
| 127 | - | |
| 128 | - if ( ! is_string( $event ) ) { | |
| 129 | - WcLogger::logArgumentTypeError( __METHOD__, 'event', 'string', $event ); | |
| 130 | - | |
| 131 | - return; | |
| 132 | - } | |
| 133 | - | |
| 134 | - if ( ! is_int( $orderId ) ) { | |
| 135 | - WcLogger::logArgumentTypeError( __METHOD__, 'orderId', 'int', $orderId ); | |
| 136 | - | |
| 137 | 113 | return; |
| 138 | 114 | } |
| 139 | 115 | |
| 140 | 116 | $wcOrder = $this->orderRepository->getWcOrderById( $orderId ); |