Test Failed
Push — feature/post-pay ( d719f9...02b246 )
by Reüel
06:15
created
src/OrderResult.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param Money      $paid_amount           Paid amount.
96 96
 	 * @param Money      $total_amount          Total amount.
97 97
 	 */
98
-	public function __construct( $merchant_order_id, $omnikassa_order_id, $poi_id, $order_status, $order_status_datetime, $error_code, Money $paid_amount, Money $total_amount ) {
98
+	public function __construct($merchant_order_id, $omnikassa_order_id, $poi_id, $order_status, $order_status_datetime, $error_code, Money $paid_amount, Money $total_amount) {
99 99
 		$this->merchant_order_id     = $merchant_order_id;
100 100
 		$this->omnikassa_order_id    = $omnikassa_order_id;
101 101
 		$this->poi_id                = $poi_id;
@@ -203,37 +203,37 @@  discard block
 block discarded – undo
203 203
 	 * @return OrderResult
204 204
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
205 205
 	 */
206
-	public static function from_object( stdClass $object ) {
207
-		if ( ! isset( $object->merchantOrderId ) ) {
208
-			throw new InvalidArgumentException( 'Object must contain `merchantOrderId` property.' );
206
+	public static function from_object(stdClass $object) {
207
+		if ( ! isset($object->merchantOrderId)) {
208
+			throw new InvalidArgumentException('Object must contain `merchantOrderId` property.');
209 209
 		}
210 210
 
211
-		if ( ! isset( $object->omnikassaOrderId ) ) {
212
-			throw new InvalidArgumentException( 'Object must contain `omnikassaOrderId` property.' );
211
+		if ( ! isset($object->omnikassaOrderId)) {
212
+			throw new InvalidArgumentException('Object must contain `omnikassaOrderId` property.');
213 213
 		}
214 214
 
215
-		if ( ! isset( $object->poiId ) ) {
216
-			throw new InvalidArgumentException( 'Object must contain `poiId` property.' );
215
+		if ( ! isset($object->poiId)) {
216
+			throw new InvalidArgumentException('Object must contain `poiId` property.');
217 217
 		}
218 218
 
219
-		if ( ! isset( $object->orderStatus ) ) {
220
-			throw new InvalidArgumentException( 'Object must contain `orderStatus` property.' );
219
+		if ( ! isset($object->orderStatus)) {
220
+			throw new InvalidArgumentException('Object must contain `orderStatus` property.');
221 221
 		}
222 222
 
223
-		if ( ! isset( $object->orderStatusDateTime ) ) {
224
-			throw new InvalidArgumentException( 'Object must contain `orderStatusDateTime` property.' );
223
+		if ( ! isset($object->orderStatusDateTime)) {
224
+			throw new InvalidArgumentException('Object must contain `orderStatusDateTime` property.');
225 225
 		}
226 226
 
227
-		if ( ! isset( $object->errorCode ) ) {
228
-			throw new InvalidArgumentException( 'Object must contain `errorCode` property.' );
227
+		if ( ! isset($object->errorCode)) {
228
+			throw new InvalidArgumentException('Object must contain `errorCode` property.');
229 229
 		}
230 230
 
231
-		if ( ! isset( $object->paidAmount ) ) {
232
-			throw new InvalidArgumentException( 'Object must contain `paidAmount` property.' );
231
+		if ( ! isset($object->paidAmount)) {
232
+			throw new InvalidArgumentException('Object must contain `paidAmount` property.');
233 233
 		}
234 234
 
235
-		if ( ! isset( $object->totalAmount ) ) {
236
-			throw new InvalidArgumentException( 'Object must contain `totalAmount` property.' );
235
+		if ( ! isset($object->totalAmount)) {
236
+			throw new InvalidArgumentException('Object must contain `totalAmount` property.');
237 237
 		}
238 238
 
239 239
 		return new self(
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 			$object->orderStatus,
244 244
 			$object->orderStatusDateTime,
245 245
 			$object->errorCode,
246
-			Money::from_object( $object->paidAmount ),
247
-			Money::from_object( $object->totalAmount )
246
+			Money::from_object($object->paidAmount),
247
+			Money::from_object($object->totalAmount)
248 248
 		);
249 249
 	}
250 250
 
@@ -255,19 +255,19 @@  discard block
 block discarded – undo
255 255
 	 * @return OrderResult
256 256
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
257 257
 	 */
258
-	public static function from_json( $json ) {
259
-		$data = json_decode( $json );
258
+	public static function from_json($json) {
259
+		$data = json_decode($json);
260 260
 
261 261
 		$validator = new Validator();
262 262
 
263 263
 		$validator->validate(
264 264
 			$data,
265 265
 			(object) array(
266
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-order-result.json' ),
266
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-order-result.json'),
267 267
 			),
268 268
 			Constraint::CHECK_MODE_EXCEPTIONS
269 269
 		);
270 270
 
271
-		return self::from_object( $data );
271
+		return self::from_object($data);
272 272
 	}
273 273
 }
Please login to merge, or discard this patch.
src/Notification.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param int|string $poi_id         POI ID.
62 62
 	 * @param string     $signature      Signature.
63 63
 	 */
64
-	public function __construct( $authentication, $expiry, $event_name, $poi_id, $signature ) {
65
-		parent::__construct( $signature );
64
+	public function __construct($authentication, $expiry, $event_name, $poi_id, $signature) {
65
+		parent::__construct($signature);
66 66
 
67 67
 		$this->authentication = $authentication;
68 68
 		$this->expiry         = $expiry;
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @return bool True if notice authentication token is epxired, false otherwise.
95 95
 	 */
96 96
 	public function is_expired() {
97
-		$timestamp = strtotime( $this->get_expiry() );
97
+		$timestamp = strtotime($this->get_expiry());
98 98
 
99
-		if ( false === $timestamp ) {
99
+		if (false === $timestamp) {
100 100
 			return true;
101 101
 		}
102 102
 
@@ -142,25 +142,25 @@  discard block
 block discarded – undo
142 142
 	 * @return Notification
143 143
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
144 144
 	 */
145
-	public static function from_object( stdClass $object ) {
146
-		if ( ! isset( $object->signature ) ) {
147
-			throw new InvalidArgumentException( 'Object must contain `signature` property.' );
145
+	public static function from_object(stdClass $object) {
146
+		if ( ! isset($object->signature)) {
147
+			throw new InvalidArgumentException('Object must contain `signature` property.');
148 148
 		}
149 149
 
150
-		if ( ! isset( $object->authentication ) ) {
151
-			throw new InvalidArgumentException( 'Object must contain `authentication` property.' );
150
+		if ( ! isset($object->authentication)) {
151
+			throw new InvalidArgumentException('Object must contain `authentication` property.');
152 152
 		}
153 153
 
154
-		if ( ! isset( $object->expiry ) ) {
155
-			throw new InvalidArgumentException( 'Object must contain `expiry` property.' );
154
+		if ( ! isset($object->expiry)) {
155
+			throw new InvalidArgumentException('Object must contain `expiry` property.');
156 156
 		}
157 157
 
158
-		if ( ! isset( $object->eventName ) ) {
159
-			throw new InvalidArgumentException( 'Object must contain `eventName` property.' );
158
+		if ( ! isset($object->eventName)) {
159
+			throw new InvalidArgumentException('Object must contain `eventName` property.');
160 160
 		}
161 161
 
162
-		if ( ! isset( $object->poiId ) ) {
163
-			throw new InvalidArgumentException( 'Object must contain `poiId` property.' );
162
+		if ( ! isset($object->poiId)) {
163
+			throw new InvalidArgumentException('Object must contain `poiId` property.');
164 164
 		}
165 165
 
166 166
 		return new self(
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 	 * @return Notification
180 180
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
181 181
 	 */
182
-	public static function from_json( $json ) {
183
-		$data = json_decode( $json );
182
+	public static function from_json($json) {
183
+		$data = json_decode($json);
184 184
 
185 185
 		$validator = new Validator();
186 186
 
187 187
 		$validator->validate(
188 188
 			$data,
189 189
 			(object) array(
190
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/notification.json' ),
190
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/notification.json'),
191 191
 			),
192 192
 			Constraint::CHECK_MODE_EXCEPTIONS
193 193
 		);
194 194
 
195
-		return self::from_object( $data );
195
+		return self::from_object($data);
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.
src/Error.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param string $code    Code.
46 46
 	 * @param string $message Message.
47 47
 	 */
48
-	public function __construct( $code, $message ) {
48
+	public function __construct($code, $message) {
49 49
 		$this->code    = $code;
50 50
 		$this->message = $message;
51 51
 	}
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 	 * @return Error
76 76
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
77 77
 	 */
78
-	public static function from_object( stdClass $object ) {
79
-		if ( ! isset( $object->errorCode ) ) {
80
-			throw new InvalidArgumentException( 'Object must contain `errorCode` property.' );
78
+	public static function from_object(stdClass $object) {
79
+		if ( ! isset($object->errorCode)) {
80
+			throw new InvalidArgumentException('Object must contain `errorCode` property.');
81 81
 		}
82 82
 
83 83
 		$message = null;
84 84
 
85
-		if ( isset( $object->errorMessage ) ) {
85
+		if (isset($object->errorMessage)) {
86 86
 			$message = $object->errorMessage;
87 87
 		}
88 88
 
89
-		if ( isset( $object->consumerMessage ) ) {
89
+		if (isset($object->consumerMessage)) {
90 90
 			$message = $object->consumerMessage;
91 91
 		}
92 92
 
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
103 103
 	 * @return Error
104 104
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
105 105
 	 */
106
-	public static function from_json( $json ) {
107
-		$data = json_decode( $json );
106
+	public static function from_json($json) {
107
+		$data = json_decode($json);
108 108
 
109 109
 		$validator = new Validator();
110 110
 
111 111
 		$validator->validate(
112 112
 			$data,
113 113
 			(object) array(
114
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-error.json' ),
114
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-error.json'),
115 115
 			),
116 116
 			Constraint::CHECK_MODE_EXCEPTIONS
117 117
 		);
118 118
 
119
-		return self::from_object( $data );
119
+		return self::from_object($data);
120 120
 	}
121 121
 }
Please login to merge, or discard this patch.
src/ConfigFactory.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@
 block discarded – undo
26 26
 	 * @param string $post_id Post ID.
27 27
 	 * @return Config
28 28
 	 */
29
-	public function get_config( $post_id ) {
29
+	public function get_config($post_id) {
30 30
 		$config = new Config();
31 31
 
32
-		$config->post_id                  = intval( $post_id );
33
-		$config->mode                     = $this->get_meta( $post_id, 'mode' );
34
-		$config->refresh_token            = $this->get_meta( $post_id, 'omnikassa_2_refresh_token' );
35
-		$config->signing_key              = $this->get_meta( $post_id, 'omnikassa_2_signing_key' );
36
-		$config->access_token             = $this->get_meta( $post_id, 'omnikassa_2_access_token' );
37
-		$config->access_token_valid_until = $this->get_meta( $post_id, 'omnikassa_2_access_token_valid_until' );
38
-		$config->order_id                 = $this->get_meta( $post_id, 'omnikassa_2_order_id' );
32
+		$config->post_id                  = intval($post_id);
33
+		$config->mode                     = $this->get_meta($post_id, 'mode');
34
+		$config->refresh_token            = $this->get_meta($post_id, 'omnikassa_2_refresh_token');
35
+		$config->signing_key              = $this->get_meta($post_id, 'omnikassa_2_signing_key');
36
+		$config->access_token             = $this->get_meta($post_id, 'omnikassa_2_access_token');
37
+		$config->access_token_valid_until = $this->get_meta($post_id, 'omnikassa_2_access_token_valid_until');
38
+		$config->order_id                 = $this->get_meta($post_id, 'omnikassa_2_order_id');
39 39
 
40 40
 		return $config;
41 41
 	}
Please login to merge, or discard this patch.
src/Address.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @param string $first_name First name.
106 106
 	 */
107
-	public function set_first_name( $first_name ) {
107
+	public function set_first_name($first_name) {
108 108
 		$this->first_name = $first_name;
109 109
 	}
110 110
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param string $middle_name Middle name.
124 124
 	 */
125
-	public function set_middle_name( $middle_name ) {
125
+	public function set_middle_name($middle_name) {
126 126
 		$this->middle_name = $middle_name;
127 127
 	}
128 128
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param string $last_name Last name.
142 142
 	 */
143
-	public function set_last_name( $last_name ) {
143
+	public function set_last_name($last_name) {
144 144
 		$this->last_name = $last_name;
145 145
 	}
146 146
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param string $street Street.
160 160
 	 */
161
-	public function set_street( $street ) {
161
+	public function set_street($street) {
162 162
 		$this->street = $street;
163 163
 	}
164 164
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @param string $house_number House number.
178 178
 	 */
179
-	public function set_house_number( $house_number ) {
179
+	public function set_house_number($house_number) {
180 180
 		$this->house_number = $house_number;
181 181
 	}
182 182
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @param string $house_number_addition House number addition.
196 196
 	 */
197
-	public function set_house_number_addition( $house_number_addition ) {
197
+	public function set_house_number_addition($house_number_addition) {
198 198
 		$this->house_number_addition = $house_number_addition;
199 199
 	}
200 200
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @param string $postal_code Postal code.
214 214
 	 */
215
-	public function set_postal_code( $postal_code ) {
215
+	public function set_postal_code($postal_code) {
216 216
 		$this->postal_code = $postal_code;
217 217
 	}
218 218
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 *
231 231
 	 * @param string $city City.
232 232
 	 */
233
-	public function set_city( $city ) {
233
+	public function set_city($city) {
234 234
 		$this->city = $city;
235 235
 	}
236 236
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param string $country_code Country code.
250 250
 	 */
251
-	public function set_country_code( $country_code ) {
251
+	public function set_country_code($country_code) {
252 252
 		$this->country_code = $country_code;
253 253
 	}
254 254
 
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 			'countryCode'         => $this->country_code,
271 271
 		);
272 272
 
273
-		$data = array_filter( $data );
273
+		$data = array_filter($data);
274 274
 
275
-		if ( empty( $data ) ) {
275
+		if (empty($data)) {
276 276
 			return null;
277 277
 		}
278 278
 
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 		);
295 295
 
296 296
 		// Optional house number fields.
297
-		if ( null !== $this->house_number ) {
297
+		if (null !== $this->house_number) {
298 298
 			$data[] = $this->house_number;
299 299
 		}
300 300
 
301
-		if ( null !== $this->house_number_addition ) {
301
+		if (null !== $this->house_number_addition) {
302 302
 			$data[] = $this->house_number_addition;
303 303
 		}
304 304
 
Please login to merge, or discard this patch.
src/Money.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param string $currency Authentication.
45 45
 	 * @param int    $amount   Amount in cents.
46 46
 	 */
47
-	public function __construct( $currency, $amount ) {
47
+	public function __construct($currency, $amount) {
48 48
 		$this->currency = $currency;
49 49
 		$this->amount   = $amount;
50 50
 	}
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 	 * @return Money
87 87
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
88 88
 	 */
89
-	public static function from_object( stdClass $object ) {
90
-		if ( ! isset( $object->currency ) ) {
91
-			throw new InvalidArgumentException( 'Object must contain `currency` property.' );
89
+	public static function from_object(stdClass $object) {
90
+		if ( ! isset($object->currency)) {
91
+			throw new InvalidArgumentException('Object must contain `currency` property.');
92 92
 		}
93 93
 
94
-		if ( ! isset( $object->amount ) ) {
95
-			throw new InvalidArgumentException( 'Object must contain `amount` property.' );
94
+		if ( ! isset($object->amount)) {
95
+			throw new InvalidArgumentException('Object must contain `amount` property.');
96 96
 		}
97 97
 
98 98
 		return new self(
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 	 * @return Money
109 109
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
110 110
 	 */
111
-	public static function from_json( $json ) {
112
-		$data = json_decode( $json );
111
+	public static function from_json($json) {
112
+		$data = json_decode($json);
113 113
 
114 114
 		$validator = new Validator();
115 115
 
116 116
 		$validator->validate(
117 117
 			$data,
118 118
 			(object) array(
119
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/json-schema-money.json' ),
119
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/json-schema-money.json'),
120 120
 			),
121 121
 			Constraint::CHECK_MODE_EXCEPTIONS
122 122
 		);
123 123
 
124
-		return self::from_object( $data );
124
+		return self::from_object($data);
125 125
 	}
126 126
 }
Please login to merge, or discard this patch.
src/OrderItems.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param array $items Order items.
32 32
 	 */
33
-	public function __construct( $items = null ) {
34
-		if ( is_array( $items ) ) {
35
-			foreach ( $items as $item ) {
36
-				$this->add_item( $item );
33
+	public function __construct($items = null) {
34
+		if (is_array($items)) {
35
+			foreach ($items as $item) {
36
+				$this->add_item($item);
37 37
 			}
38 38
 		}
39 39
 	}
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return void
47 47
 	 */
48
-	public function add_item( $order_item ) {
49
-		if ( ! ( $order_item instanceof OrderItem ) ) {
50
-			$order_item = new OrderItem( $order_item );
48
+	public function add_item($order_item) {
49
+		if ( ! ($order_item instanceof OrderItem)) {
50
+			$order_item = new OrderItem($order_item);
51 51
 		}
52 52
 
53 53
 		$this->order_items[] = $order_item;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 		$items = $this->get_order_items();
74 74
 
75
-		foreach ( $items as $item ) {
75
+		foreach ($items as $item) {
76 76
 			$amount = $item->get_amount();
77 77
 			$tax    = $item->get_tax();
78 78
 
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 				'name'        => $item->get_name(),
82 82
 				'description' => $item->get_description(),
83 83
 				'quantity'    => $item->get_quantity(),
84
-				'amount'      => ( $amount instanceof Money ) ? $amount->get_json() : null,
85
-				'tax'         => ( $tax instanceof Money ) ? $tax->get_json() : null,
84
+				'amount'      => ($amount instanceof Money) ? $amount->get_json() : null,
85
+				'tax'         => ($tax instanceof Money) ? $tax->get_json() : null,
86 86
 				'category'    => $item->get_category(),
87 87
 				'vatCategory' => $item->get_vat_category(),
88 88
 			);
89 89
 
90
-			$item_data = array_filter( $item_data );
90
+			$item_data = array_filter($item_data);
91 91
 
92
-			if ( ! empty( $item_data ) ) {
92
+			if ( ! empty($item_data)) {
93 93
 				$data[] = (object) $item_data;
94 94
 			}
95 95
 		}
96 96
 
97
-		if ( empty( $data ) ) {
97
+		if (empty($data)) {
98 98
 			return null;
99 99
 		}
100 100
 
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$order_items = $this->get_order_items();
113 113
 
114
-		foreach ( $order_items as $item ) {
114
+		foreach ($order_items as $item) {
115 115
 			// Optional ID.
116 116
 			$item_id = $item->get_id();
117 117
 
118
-			if ( ! empty( $item_id ) ) {
118
+			if ( ! empty($item_id)) {
119 119
 				$data[] = $item_id;
120 120
 			}
121 121
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 			// Required tax field.
130 130
 			$tax = $item->get_tax();
131 131
 
132
-			if ( empty( $tax ) ) {
132
+			if (empty($tax)) {
133 133
 				$data[] = $tax;
134 134
 			} else {
135 135
 				$data[] = $tax->get_currency();
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 			// Optional VAT category.
143 143
 			$vat_category = $item->get_vat_category();
144 144
 
145
-			if ( ! empty( $vat_category ) ) {
145
+			if ( ! empty($vat_category)) {
146 146
 				$data[] = $vat_category;
147 147
 			}
148 148
 		}
Please login to merge, or discard this patch.
src/PaymentBrands.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,13 +113,13 @@
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string|null
115 115
 	 */
116
-	public static function transform( $payment_method, $default = null ) {
117
-		if ( ! is_scalar( $payment_method ) ) {
116
+	public static function transform($payment_method, $default = null) {
117
+		if ( ! is_scalar($payment_method)) {
118 118
 			return null;
119 119
 		}
120 120
 
121
-		if ( isset( self::$map[ $payment_method ] ) ) {
122
-			return self::$map[ $payment_method ];
121
+		if (isset(self::$map[$payment_method])) {
122
+			return self::$map[$payment_method];
123 123
 		}
124 124
 
125 125
 		return $default;
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -35,23 +35,23 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param Config $config Config.
37 37
 	 */
38
-	public function __construct( Config $config ) {
39
-		parent::__construct( $config );
38
+	public function __construct(Config $config) {
39
+		parent::__construct($config);
40 40
 
41
-		$this->set_method( self::METHOD_HTTP_REDIRECT );
41
+		$this->set_method(self::METHOD_HTTP_REDIRECT);
42 42
 
43 43
 		// Client.
44 44
 		$this->client = new Client();
45 45
 
46 46
 		$url = Client::URL_PRODUCTION;
47 47
 
48
-		if ( self::MODE_TEST === $config->mode ) {
48
+		if (self::MODE_TEST === $config->mode) {
49 49
 			$url = Client::URL_SANDBOX;
50 50
 		}
51 51
 
52
-		$this->client->set_url( $url );
53
-		$this->client->set_refresh_token( $config->refresh_token );
54
-		$this->client->set_signing_key( $config->signing_key );
52
+		$this->client->set_url($url);
53
+		$this->client->set_refresh_token($config->refresh_token);
54
+		$this->client->set_signing_key($config->signing_key);
55 55
 	}
56 56
 
57 57
 	/**
@@ -78,87 +78,87 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param Payment $payment Payment.
80 80
 	 */
81
-	public function start( Payment $payment ) {
81
+	public function start(Payment $payment) {
82 82
 		// Merchant order ID.
83
-		$merchant_order_id = $payment->format_string( $this->config->order_id );
83
+		$merchant_order_id = $payment->format_string($this->config->order_id);
84 84
 
85
-		$payment->set_meta( 'omnikassa_2_merchant_order_id', $merchant_order_id );
85
+		$payment->set_meta('omnikassa_2_merchant_order_id', $merchant_order_id);
86 86
 
87 87
 		// Billing and shipping details.
88 88
 		$shipping_address = $payment->get_shipping_address();
89 89
 		$billing_address  = $payment->get_billing_address();
90 90
 
91 91
 		$shipping_detail = new Address();
92
-		$shipping_detail->set_first_name( $shipping_address->get_name()->get_first_name() );
93
-		$shipping_detail->set_middle_name( $shipping_address->get_name()->get_middle_name() );
94
-		$shipping_detail->set_last_name( $shipping_address->get_name()->get_last_name() );
95
-		$shipping_detail->set_street( $shipping_address->get_street_name() );
96
-		$shipping_detail->set_house_number( $shipping_address->get_house_number() );
97
-		$shipping_detail->set_house_number_addition( $shipping_address->get_house_number_addition() );
98
-		$shipping_detail->set_postal_code( $shipping_address->get_postal_code() );
99
-		$shipping_detail->set_city( $shipping_address->get_city() );
100
-		$shipping_detail->set_country_code( $shipping_address->get_country_code() );
92
+		$shipping_detail->set_first_name($shipping_address->get_name()->get_first_name());
93
+		$shipping_detail->set_middle_name($shipping_address->get_name()->get_middle_name());
94
+		$shipping_detail->set_last_name($shipping_address->get_name()->get_last_name());
95
+		$shipping_detail->set_street($shipping_address->get_street_name());
96
+		$shipping_detail->set_house_number($shipping_address->get_house_number());
97
+		$shipping_detail->set_house_number_addition($shipping_address->get_house_number_addition());
98
+		$shipping_detail->set_postal_code($shipping_address->get_postal_code());
99
+		$shipping_detail->set_city($shipping_address->get_city());
100
+		$shipping_detail->set_country_code($shipping_address->get_country_code());
101 101
 
102 102
 		$billing_detail = new Address();
103
-		$billing_detail->set_first_name( $billing_address->get_name()->get_first_name() );
104
-		$billing_detail->set_middle_name( $billing_address->get_name()->get_middle_name() );
105
-		$billing_detail->set_last_name( $billing_address->get_name()->get_last_name() );
106
-		$billing_detail->set_street( $billing_address->get_street_name() );
107
-		$billing_detail->set_house_number( $billing_address->get_house_number() );
108
-		$billing_detail->set_house_number_addition( $billing_address->get_house_number_addition() );
109
-		$billing_detail->set_postal_code( $billing_address->get_postal_code() );
110
-		$billing_detail->set_city( $billing_address->get_city() );
111
-		$billing_detail->set_country_code( $billing_address->get_country_code() );
103
+		$billing_detail->set_first_name($billing_address->get_name()->get_first_name());
104
+		$billing_detail->set_middle_name($billing_address->get_name()->get_middle_name());
105
+		$billing_detail->set_last_name($billing_address->get_name()->get_last_name());
106
+		$billing_detail->set_street($billing_address->get_street_name());
107
+		$billing_detail->set_house_number($billing_address->get_house_number());
108
+		$billing_detail->set_house_number_addition($billing_address->get_house_number_addition());
109
+		$billing_detail->set_postal_code($billing_address->get_postal_code());
110
+		$billing_detail->set_city($billing_address->get_city());
111
+		$billing_detail->set_country_code($billing_address->get_country_code());
112 112
 
113 113
 		// Customer information.
114 114
 		$customer_information = new CustomerInformation();
115
-		$customer_information->set_email_address( $payment->get_contact()->get_email() );
116
-		$customer_information->set_telephone_number( $payment->get_contact()->get_phone() );
115
+		$customer_information->set_email_address($payment->get_contact()->get_email());
116
+		$customer_information->set_telephone_number($payment->get_contact()->get_phone());
117 117
 
118 118
 		// Payment brand.
119
-		$payment_brand = PaymentBrands::transform( $payment->get_method() );
119
+		$payment_brand = PaymentBrands::transform($payment->get_method());
120 120
 
121 121
 		// New order.
122 122
 		$order = new Order(
123 123
 			$merchant_order_id,
124 124
 			new Money(
125 125
 				$payment->get_currency(),
126
-				Core_Util::amount_to_cents( $payment->get_amount()->get_amount() )
126
+				Core_Util::amount_to_cents($payment->get_amount()->get_amount())
127 127
 			),
128 128
 			$payment->get_return_url()
129 129
 		);
130 130
 
131
-		$order->set_description( $payment->get_description() );
132
-		$order->set_language( $payment->get_contact()->get_language() );
133
-		$order->set_items( $payment->get_order_items() );
134
-		$order->set_shipping_detail( $shipping_detail );
135
-		$order->set_billing_detail( $billing_detail );
136
-		$order->set_customer_information( $customer_information );
137
-		$order->set_payment_brand( $payment_brand );
131
+		$order->set_description($payment->get_description());
132
+		$order->set_language($payment->get_contact()->get_language());
133
+		$order->set_items($payment->get_order_items());
134
+		$order->set_shipping_detail($shipping_detail);
135
+		$order->set_billing_detail($billing_detail);
136
+		$order->set_customer_information($customer_information);
137
+		$order->set_payment_brand($payment_brand);
138 138
 
139
-		if ( null !== $payment_brand ) {
139
+		if (null !== $payment_brand) {
140 140
 			// Payment brand force should only be set if payment brand is not empty.
141
-			$order->set_payment_brand_force( PaymentBrandForce::FORCE_ONCE );
141
+			$order->set_payment_brand_force(PaymentBrandForce::FORCE_ONCE);
142 142
 		}
143 143
 
144 144
 		// Maybe update access token.
145 145
 		$this->maybe_update_access_token();
146 146
 
147 147
 		// Handle errors.
148
-		if ( $this->get_client_error() ) {
148
+		if ($this->get_client_error()) {
149 149
 			return;
150 150
 		}
151 151
 
152 152
 		// Announce order.
153
-		$result = $this->client->order_announce( $this->config, $order );
153
+		$result = $this->client->order_announce($this->config, $order);
154 154
 
155 155
 		// Handle errors.
156
-		if ( $this->get_client_error() ) {
156
+		if ($this->get_client_error()) {
157 157
 			return;
158 158
 		}
159 159
 
160
-		if ( $result ) {
161
-			$payment->set_action_url( $result->redirectUrl );
160
+		if ($result) {
161
+			$payment->set_action_url($result->redirectUrl);
162 162
 		}
163 163
 	}
164 164
 
@@ -167,45 +167,45 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @param Payment $payment Payment.
169 169
 	 */
170
-	public function update_status( Payment $payment ) {
171
-		if ( ! ReturnParameters::contains( $_GET ) ) { // WPCS: CSRF ok.
170
+	public function update_status(Payment $payment) {
171
+		if ( ! ReturnParameters::contains($_GET)) { // WPCS: CSRF ok.
172 172
 			return;
173 173
 		}
174 174
 
175
-		$parameters = ReturnParameters::from_array( $_GET ); // WPCS: CSRF ok.
175
+		$parameters = ReturnParameters::from_array($_GET); // WPCS: CSRF ok.
176 176
 
177 177
 		// Note.
178 178
 		$note_values = array(
179 179
 			'order_id'  => $parameters->get_order_id(),
180 180
 			'status'    => $parameters->get_status(),
181 181
 			'signature' => $parameters->get_signature(),
182
-			'valid'     => $parameters->is_valid( $this->config->signing_key ) ? 'true' : 'false',
182
+			'valid'     => $parameters->is_valid($this->config->signing_key) ? 'true' : 'false',
183 183
 		);
184 184
 
185 185
 		$note = '';
186 186
 
187 187
 		$note .= '<p>';
188
-		$note .= __( 'OmniKassa 2.0 return URL requested:', 'pronamic_ideal' );
188
+		$note .= __('OmniKassa 2.0 return URL requested:', 'pronamic_ideal');
189 189
 		$note .= '</p>';
190 190
 
191 191
 		$note .= '<dl>';
192 192
 
193
-		foreach ( $note_values as $key => $value ) {
194
-			$note .= sprintf( '<dt>%s</dt>', esc_html( $key ) );
195
-			$note .= sprintf( '<dd>%s</dd>', esc_html( $value ) );
193
+		foreach ($note_values as $key => $value) {
194
+			$note .= sprintf('<dt>%s</dt>', esc_html($key));
195
+			$note .= sprintf('<dd>%s</dd>', esc_html($value));
196 196
 		}
197 197
 
198 198
 		$note .= '</dl>';
199 199
 
200
-		$payment->add_note( $note );
200
+		$payment->add_note($note);
201 201
 
202 202
 		// Validate.
203
-		if ( ! $parameters->is_valid( $this->config->signing_key ) ) {
203
+		if ( ! $parameters->is_valid($this->config->signing_key)) {
204 204
 			return;
205 205
 		}
206 206
 
207 207
 		// Status.
208
-		$payment->set_status( Statuses::transform( $parameters->get_status() ) );
208
+		$payment->set_status(Statuses::transform($parameters->get_status()));
209 209
 	}
210 210
 
211 211
 	/**
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return void
217 217
 	 */
218
-	public function handle_notification( Notification $notification ) {
219
-		if ( ! $notification->is_valid( $this->config->signing_key ) ) {
218
+	public function handle_notification(Notification $notification) {
219
+		if ( ! $notification->is_valid($this->config->signing_key)) {
220 220
 			return;
221 221
 		}
222 222
 
223
-		switch ( $notification->get_event_name() ) {
223
+		switch ($notification->get_event_name()) {
224 224
 			case 'merchant.order.status.changed':
225
-				$this->handle_merchant_order_status_changed( $notification );
225
+				$this->handle_merchant_order_status_changed($notification);
226 226
 		}
227 227
 	}
228 228
 
@@ -233,39 +233,39 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return void
235 235
 	 */
236
-	private function handle_merchant_order_status_changed( Notification $notification ) {
236
+	private function handle_merchant_order_status_changed(Notification $notification) {
237 237
 		do {
238
-			$order_results = $this->client->get_order_results( $notification->get_authentication() );
238
+			$order_results = $this->client->get_order_results($notification->get_authentication());
239 239
 
240
-			if ( ! $order_results || $order_results->is_valid( $this->config->signing_key ) ) {
240
+			if ( ! $order_results || $order_results->is_valid($this->config->signing_key)) {
241 241
 				return;
242 242
 			}
243 243
 
244
-			foreach ( $order_results as $order_result ) {
245
-				$payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id() );
244
+			foreach ($order_results as $order_result) {
245
+				$payment = get_pronamic_payment_by_meta('_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id());
246 246
 
247
-				if ( empty( $payment ) ) {
247
+				if (empty($payment)) {
248 248
 					continue;
249 249
 				}
250 250
 
251
-				$payment->set_transaction_id( $order_result->get_omnikassa_order_id() );
252
-				$payment->set_status( Statuses::transform( $order_result->get_order_status() ) );
251
+				$payment->set_transaction_id($order_result->get_omnikassa_order_id());
252
+				$payment->set_status(Statuses::transform($order_result->get_order_status()));
253 253
 
254 254
 				// Note.
255 255
 				$note = '';
256 256
 
257 257
 				$note .= '<p>';
258
-				$note .= __( 'OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal' );
258
+				$note .= __('OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal');
259 259
 				$note .= '</p>';
260 260
 				$note .= '<pre>';
261
-				$note .= wp_json_encode( $order_result->get_json(), JSON_PRETTY_PRINT );
261
+				$note .= wp_json_encode($order_result->get_json(), JSON_PRETTY_PRINT);
262 262
 				$note .= '</pre>';
263 263
 
264
-				$payment->add_note( $note );
264
+				$payment->add_note($note);
265 265
 
266 266
 				$payment->save();
267 267
 			}
268
-		} while ( $order_results->more_available() );
268
+		} while ($order_results->more_available());
269 269
 	}
270 270
 
271 271
 	/**
@@ -274,20 +274,20 @@  discard block
 block discarded – undo
274 274
 	 * @return void
275 275
 	 */
276 276
 	private function maybe_update_access_token() {
277
-		if ( $this->config->is_access_token_valid() ) {
277
+		if ($this->config->is_access_token_valid()) {
278 278
 			return;
279 279
 		}
280 280
 
281 281
 		$data = $this->client->get_access_token_data();
282 282
 
283
-		if ( ! is_object( $data ) ) {
283
+		if ( ! is_object($data)) {
284 284
 			return;
285 285
 		}
286 286
 
287 287
 		$this->config->access_token             = $data->token;
288 288
 		$this->config->access_token_valid_until = $data->validUntil;
289 289
 
290
-		update_post_meta( $this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token );
290
+		update_post_meta($this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token);
291 291
 		update_post_meta(
292 292
 			$this->config->post_id,
293 293
 			'_pronamic_gateway_omnikassa_2_access_token_valid_until',
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	private function get_client_error() {
304 304
 		$error = $this->client->get_error();
305 305
 
306
-		if ( is_wp_error( $error ) ) {
306
+		if (is_wp_error($error)) {
307 307
 			$this->error = $error;
308 308
 
309 309
 			return $error;
Please login to merge, or discard this patch.