Test Failed
Push — feature/post-pay ( c18430...6a63dc )
by Reüel
07:10
created
src/Security.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param array $fields Fields.
27 27
 	 * @return string
28 28
 	 */
29
-	public static function get_signature_fields_combined( $fields ) {
30
-		return implode( ',', $fields );
29
+	public static function get_signature_fields_combined($fields) {
30
+		return implode(',', $fields);
31 31
 	}
32 32
 
33 33
 	/**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * @return string
39 39
 	 * @throws InvalidArgumentException Signing key is invalid.
40 40
 	 */
41
-	public static function get_signature( Signable $signable, $signing_key ) {
42
-		if ( empty( $signing_key ) ) {
41
+	public static function get_signature(Signable $signable, $signing_key) {
42
+		if (empty($signing_key)) {
43 43
 			throw new InvalidArgumentException(
44 44
 				sprintf(
45 45
 					'Signing key "%s" is empty.',
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 			);
49 49
 		}
50 50
 
51
-		$decoded_signing_key = base64_decode( $signing_key );
51
+		$decoded_signing_key = base64_decode($signing_key);
52 52
 
53
-		if ( false === $decoded_signing_key ) {
53
+		if (false === $decoded_signing_key) {
54 54
 			throw new InvalidArgumentException(
55 55
 				sprintf(
56 56
 					'Signing key "%s" contains character from outside the base64 alphabet.',
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$fields = $signable->get_signature_fields();
63 63
 
64
-		$combined = self::get_signature_fields_combined( $fields );
64
+		$combined = self::get_signature_fields_combined($fields);
65 65
 
66 66
 		$signature = hash_hmac(
67 67
 			'sha512',
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 * @param string $signature_b Signature B.
80 80
 	 * @return bool True if valid, false otherwise.
81 81
 	 */
82
-	public static function validate_signature( $signature_a, $signature_b ) {
83
-		if ( empty( $signature_a ) || empty( $signature_b ) ) {
82
+	public static function validate_signature($signature_a, $signature_b) {
83
+		if (empty($signature_a) || empty($signature_b)) {
84 84
 			// Empty signature string or null from calculation.
85 85
 			return false;
86 86
 		}
87 87
 
88
-		return ( 0 === strcasecmp( $signature_a, $signature_b ) );
88
+		return (0 === strcasecmp($signature_a, $signature_b));
89 89
 	}
90 90
 }
Please login to merge, or discard this patch.
src/MoneyTransformer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@
 block discarded – undo
26 26
 	 * @param PronamicMoney $pronamic_money Pronamic money to convert.
27 27
 	 * @return Money
28 28
 	 */
29
-	public static function transform( PronamicMoney $pronamic_money ) {
29
+	public static function transform(PronamicMoney $pronamic_money) {
30 30
 		$money = new Money(
31 31
 			$pronamic_money->get_currency()->get_alphabetic_code(),
32
-			intval( $pronamic_money->get_cents() )
32
+			intval($pronamic_money->get_cents())
33 33
 		);
34 34
 
35 35
 		return $money;
Please login to merge, or discard this patch.
src/OrderResults.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 	 * @param array  $order_results  Order results.
48 48
 	 * @param string $signature      Signature.
49 49
 	 */
50
-	public function __construct( $more_available, array $order_results, $signature ) {
51
-		parent::__construct( $signature );
50
+	public function __construct($more_available, array $order_results, $signature) {
51
+		parent::__construct($signature);
52 52
 
53 53
 		$this->more_available = $more_available;
54 54
 		$this->order_results  = $order_results;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 		$fields[] = $this->more_available() ? 'true' : 'false';
75 75
 
76
-		foreach ( $this->order_results as $order_result ) {
76
+		foreach ($this->order_results as $order_result) {
77 77
 			$fields[] = $order_result->get_merchant_order_id();
78 78
 			$fields[] = $order_result->get_omnikassa_order_id();
79 79
 			$fields[] = $order_result->get_poi_id();
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return ArrayIterator
96 96
 	 */
97 97
 	public function getIterator() {
98
-		return new ArrayIterator( $this->order_results );
98
+		return new ArrayIterator($this->order_results);
99 99
 	}
100 100
 
101 101
 	/**
@@ -105,27 +105,27 @@  discard block
 block discarded – undo
105 105
 	 * @return OrderResults
106 106
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
107 107
 	 */
108
-	public static function from_object( $object ) {
109
-		if ( ! isset( $object->signature ) ) {
110
-			throw new InvalidArgumentException( 'Object must contain `signature` property.' );
108
+	public static function from_object($object) {
109
+		if ( ! isset($object->signature)) {
110
+			throw new InvalidArgumentException('Object must contain `signature` property.');
111 111
 		}
112 112
 
113
-		if ( ! isset( $object->moreOrderResultsAvailable ) ) {
114
-			throw new InvalidArgumentException( 'Object must contain `moreOrderResultsAvailable` property.' );
113
+		if ( ! isset($object->moreOrderResultsAvailable)) {
114
+			throw new InvalidArgumentException('Object must contain `moreOrderResultsAvailable` property.');
115 115
 		}
116 116
 
117
-		if ( ! isset( $object->orderResults ) ) {
118
-			throw new InvalidArgumentException( 'Object must contain `orderResults` property.' );
117
+		if ( ! isset($object->orderResults)) {
118
+			throw new InvalidArgumentException('Object must contain `orderResults` property.');
119 119
 		}
120 120
 
121
-		if ( ! is_array( $object->orderResults ) ) {
122
-			throw new InvalidArgumentException( 'The `orderResults` property must be an array.' );
121
+		if ( ! is_array($object->orderResults)) {
122
+			throw new InvalidArgumentException('The `orderResults` property must be an array.');
123 123
 		}
124 124
 
125 125
 		$order_results = array();
126 126
 
127
-		foreach ( $object->orderResults as $o ) {
128
-			$order_results[] = OrderResult::from_object( $o );
127
+		foreach ($object->orderResults as $o) {
128
+			$order_results[] = OrderResult::from_object($o);
129 129
 		}
130 130
 
131 131
 		return new self(
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 	 * @return OrderResults
143 143
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
144 144
 	 */
145
-	public static function from_json( $json ) {
146
-		$data = json_decode( $json );
145
+	public static function from_json($json) {
146
+		$data = json_decode($json);
147 147
 
148 148
 		$validator = new Validator();
149 149
 
150 150
 		$validator->validate(
151 151
 			$data,
152 152
 			(object) array(
153
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/order-results.json' ),
153
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/order-results.json'),
154 154
 			),
155 155
 			Constraint::CHECK_MODE_EXCEPTIONS
156 156
 		);
157 157
 
158
-		return self::from_object( $data );
158
+		return self::from_object($data);
159 159
 	}
160 160
 }
Please login to merge, or discard this patch.
src/OrderAnnounceResponse.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@  discard block
 block discarded – undo
36 36
 	 * @param string $redirect_url Redirect URL.
37 37
 	 * @param string $signature    Signature.
38 38
 	 */
39
-	public function __construct( $redirect_url, $signature ) {
40
-		parent::__construct( $signature );
39
+	public function __construct($redirect_url, $signature) {
40
+		parent::__construct($signature);
41 41
 
42 42
 		$this->redirect_url = $redirect_url;
43 43
 	}
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	 * @return OrderAnnounceResponse
70 70
 	 * @throws InvalidArgumentException Throws invalid argument exception when object does not contains the required properties.
71 71
 	 */
72
-	public static function from_object( $object ) {
73
-		if ( ! isset( $object->signature ) ) {
74
-			throw new InvalidArgumentException( 'Object must contain `signature` property.' );
72
+	public static function from_object($object) {
73
+		if ( ! isset($object->signature)) {
74
+			throw new InvalidArgumentException('Object must contain `signature` property.');
75 75
 		}
76 76
 
77
-		if ( ! isset( $object->redirectUrl ) ) {
78
-			throw new InvalidArgumentException( 'Object must contain `redirectUrl` property.' );
77
+		if ( ! isset($object->redirectUrl)) {
78
+			throw new InvalidArgumentException('Object must contain `redirectUrl` property.');
79 79
 		}
80 80
 
81 81
 		return new self(
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	 * @return OrderAnnounceResponse
92 92
 	 * @throws \JsonSchema\Exception\ValidationException Throws JSON schema validation exception when JSON is invalid.
93 93
 	 */
94
-	public static function from_json( $json ) {
95
-		$data = json_decode( $json );
94
+	public static function from_json($json) {
95
+		$data = json_decode($json);
96 96
 
97 97
 		$validator = new Validator();
98 98
 
99 99
 		$validator->validate(
100 100
 			$data,
101 101
 			(object) array(
102
-				'$ref' => 'file://' . realpath( __DIR__ . '/../json-schemas/order-announce-response.json' ),
102
+				'$ref' => 'file://' . realpath(__DIR__ . '/../json-schemas/order-announce-response.json'),
103 103
 			),
104 104
 			Constraint::CHECK_MODE_EXCEPTIONS
105 105
 		);
106 106
 
107
-		return self::from_object( $data );
107
+		return self::from_object($data);
108 108
 	}
109 109
 }
Please login to merge, or discard this patch.
src/CustomerInformation.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @param string|null $email_address E-mailadress of the consumer.
63 63
 	 */
64
-	public function set_email_address( $email_address ) {
64
+	public function set_email_address($email_address) {
65 65
 		$this->email_address = $email_address;
66 66
 	}
67 67
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param DateTime|null $date_of_birth Date of birth.
72 72
 	 */
73
-	public function set_date_of_birth( DateTime $date_of_birth = null ) {
73
+	public function set_date_of_birth(DateTime $date_of_birth = null) {
74 74
 		$this->date_of_birth = $date_of_birth;
75 75
 	}
76 76
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @param string|null $gender Gender.
81 81
 	 * @throws InvalidArgumentException Throws invalid argument exception when gender is not null, 'F' or 'M'.
82 82
 	 */
83
-	public function set_gender( $gender ) {
84
-		if ( ! in_array( $gender, array( null, 'F', 'M' ), true ) ) {
85
-			throw new InvalidArgumentException( 'Gender "%s" must be equal to `null`, "F" or "M".' );
83
+	public function set_gender($gender) {
84
+		if ( ! in_array($gender, array(null, 'F', 'M'), true)) {
85
+			throw new InvalidArgumentException('Gender "%s" must be equal to `null`, "F" or "M".');
86 86
 		}
87 87
 
88 88
 		$this->gender = $gender;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @param string|null $initials Initials.
95 95
 	 */
96
-	public function set_initials( $initials ) {
96
+	public function set_initials($initials) {
97 97
 		$this->initials = $initials;
98 98
 	}
99 99
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @param string|null $telephone_number Telephone number.
104 104
 	 */
105
-	public function set_telephone_number( $telephone_number ) {
105
+	public function set_telephone_number($telephone_number) {
106 106
 		$this->telephone_number = $telephone_number;
107 107
 	}
108 108
 
@@ -114,23 +114,23 @@  discard block
 block discarded – undo
114 114
 	public function get_json() {
115 115
 		$object = (object) array();
116 116
 
117
-		if ( null !== $this->email_address ) {
117
+		if (null !== $this->email_address) {
118 118
 			$object->emailAddress = $this->email_address;
119 119
 		}
120 120
 
121
-		if ( null !== $this->date_of_birth ) {
122
-			$object->dateOfBirth = $this->date_of_birth->format( 'd-m-Y' );
121
+		if (null !== $this->date_of_birth) {
122
+			$object->dateOfBirth = $this->date_of_birth->format('d-m-Y');
123 123
 		}
124 124
 
125
-		if ( null !== $this->gender ) {
125
+		if (null !== $this->gender) {
126 126
 			$object->gender = $this->gender;
127 127
 		}
128 128
 
129
-		if ( null !== $this->initials ) {
129
+		if (null !== $this->initials) {
130 130
 			$object->initials = $this->initials;
131 131
 		}
132 132
 
133
-		if ( null !== $this->telephone_number ) {
133
+		if (null !== $this->telephone_number) {
134 134
 			$object->telephoneNumber = $this->telephone_number;
135 135
 		}
136 136
 
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 	 * @param array $fields Fields.
144 144
 	 * @return array
145 145
 	 */
146
-	public function get_signature_fields( $fields = array() ) {
146
+	public function get_signature_fields($fields = array()) {
147 147
 		$fields[] = $this->email_address;
148
-		$fields[] = ( null === $this->date_of_birth ) ? null : $this->date_of_birth->format( 'd-m-Y' );
148
+		$fields[] = (null === $this->date_of_birth) ? null : $this->date_of_birth->format('d-m-Y');
149 149
 		$fields[] = $this->gender;
150 150
 		$fields[] = $this->initials;
151 151
 		$fields[] = $this->telephone_number;
Please login to merge, or discard this patch.
src/ProductCategories.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@
 block discarded – undo
41 41
 	 *
42 42
 	 * @return string
43 43
 	 */
44
-	public static function transform( $type ) {
45
-		switch ( $type ) {
44
+	public static function transform($type) {
45
+		switch ($type) {
46 46
 			case PaymentLineType::PHYSICAL:
47 47
 				return self::PHYSICAL;
48 48
 
Please login to merge, or discard this patch.
src/Order.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	 * @param Money  $amount               Amount.
156 156
 	 * @param string $merchant_return_url  Merchant return URL.
157 157
 	 */
158
-	public function __construct( $merchant_order_id, $amount, $merchant_return_url ) {
159
-		$this->set_timestamp( new DateTime() );
160
-		$this->set_merchant_order_id( $merchant_order_id );
161
-		$this->set_amount( $amount );
162
-		$this->set_merchant_return_url( $merchant_return_url );
158
+	public function __construct($merchant_order_id, $amount, $merchant_return_url) {
159
+		$this->set_timestamp(new DateTime());
160
+		$this->set_merchant_order_id($merchant_order_id);
161
+		$this->set_amount($amount);
162
+		$this->set_merchant_return_url($merchant_return_url);
163 163
 	}
164 164
 
165 165
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @param DateTime $timestamp Timestamp.
169 169
 	 */
170
-	public function set_timestamp( DateTime $timestamp ) {
170
+	public function set_timestamp(DateTime $timestamp) {
171 171
 		$this->timestamp = $timestamp;
172 172
 	}
173 173
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 	 * @param string $merchant_order_id Merchant order ID.
178 178
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..max 10`.
179 179
 	 */
180
-	public function set_merchant_order_id( $merchant_order_id ) {
181
-		DataHelper::validate_an( $merchant_order_id, 10 );
180
+	public function set_merchant_order_id($merchant_order_id) {
181
+		DataHelper::validate_an($merchant_order_id, 10);
182 182
 
183 183
 		$this->merchant_order_id = $merchant_order_id;
184 184
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param Money $amount Amount.
190 190
 	 */
191
-	public function set_amount( Money $amount ) {
191
+	public function set_amount(Money $amount) {
192 192
 		$this->amount = $amount;
193 193
 	}
194 194
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @param string $url Merchant return URL.
201 201
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..max 1024`.
202 202
 	 */
203
-	public function set_merchant_return_url( $url ) {
204
-		DataHelper::validate_an( $url, 1024 );
203
+	public function set_merchant_return_url($url) {
204
+		DataHelper::validate_an($url, 1024);
205 205
 
206 206
 		$this->merchant_return_url = $url;
207 207
 	}
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 * @param string|null $description Description.
213 213
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..max 35`.
214 214
 	 */
215
-	public function set_description( $description ) {
216
-		DataHelper::validate_an( $description, 35 );
215
+	public function set_description($description) {
216
+		DataHelper::validate_an($description, 35);
217 217
 
218 218
 		$this->description = $description;
219 219
 	}
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string|null $language Language.
225 225
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..2`.
226 226
 	 */
227
-	public function set_language( $language ) {
228
-		DataHelper::validate_null_or_an( $language, 2 );
227
+	public function set_language($language) {
228
+		DataHelper::validate_null_or_an($language, 2);
229 229
 
230 230
 		$this->language = $language;
231 231
 	}
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * @param string|null $payment_brand Payment brand.
237 237
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..50`.
238 238
 	 */
239
-	public function set_payment_brand( $payment_brand ) {
240
-		DataHelper::validate_null_or_an( $payment_brand, 50 );
239
+	public function set_payment_brand($payment_brand) {
240
+		DataHelper::validate_null_or_an($payment_brand, 50);
241 241
 
242 242
 		$this->payment_brand = $payment_brand;
243 243
 	}
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param string|null $payment_brand_force Payment brand force.
249 249
 	 * @throws InvalidArgumentException Throws invalid argument exception when value does not apply to format `AN..50`.
250 250
 	 */
251
-	public function set_payment_brand_force( $payment_brand_force ) {
252
-		DataHelper::validate_null_or_an( $payment_brand_force, 50 );
251
+	public function set_payment_brand_force($payment_brand_force) {
252
+		DataHelper::validate_null_or_an($payment_brand_force, 50);
253 253
 
254 254
 		$this->payment_brand_force = $payment_brand_force;
255 255
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @param OrderItems|null $order_items Order items.
272 272
 	 */
273
-	public function set_order_items( OrderItems $order_items = null ) {
273
+	public function set_order_items(OrderItems $order_items = null) {
274 274
 		$this->order_items = $order_items;
275 275
 	}
276 276
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @param Address|null $shipping_detail Shipping address details.
281 281
 	 */
282
-	public function set_shipping_detail( Address $shipping_detail = null ) {
282
+	public function set_shipping_detail(Address $shipping_detail = null) {
283 283
 		$this->shipping_detail = $shipping_detail;
284 284
 	}
285 285
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @param Address|null $billing_detail Billing address details.
290 290
 	 */
291
-	public function set_billing_detail( Address $billing_detail = null ) {
291
+	public function set_billing_detail(Address $billing_detail = null) {
292 292
 		$this->billing_detail = $billing_detail;
293 293
 	}
294 294
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @param CustomerInformation $customer_information Customer information.
299 299
 	 */
300
-	public function set_customer_information( CustomerInformation $customer_information ) {
300
+	public function set_customer_information(CustomerInformation $customer_information) {
301 301
 		$this->customer_information = $customer_information;
302 302
 	}
303 303
 
@@ -309,42 +309,42 @@  discard block
 block discarded – undo
309 309
 	public function get_json() {
310 310
 		$object = (object) array();
311 311
 
312
-		$object->timestamp       = $this->timestamp->format( DATE_ATOM );
312
+		$object->timestamp       = $this->timestamp->format(DATE_ATOM);
313 313
 		$object->merchantOrderId = $this->merchant_order_id;
314 314
 
315
-		if ( null !== $this->description ) {
315
+		if (null !== $this->description) {
316 316
 			$object->description = $this->description;
317 317
 		}
318 318
 
319
-		if ( null !== $this->order_items ) {
319
+		if (null !== $this->order_items) {
320 320
 			$object->orderItems = $this->order_items->get_json();
321 321
 		}
322 322
 
323 323
 		$object->amount = $this->amount->get_json();
324 324
 
325
-		if ( null !== $this->shipping_detail ) {
325
+		if (null !== $this->shipping_detail) {
326 326
 			$object->shippingDetail = $this->shipping_detail->get_json();
327 327
 		}
328 328
 
329
-		if ( null !== $this->billing_detail ) {
329
+		if (null !== $this->billing_detail) {
330 330
 			$object->billingDetail = $this->billing_detail->get_json();
331 331
 		}
332 332
 
333
-		if ( null !== $this->customer_information ) {
333
+		if (null !== $this->customer_information) {
334 334
 			$object->customerInformation = $this->customer_information->get_json();
335 335
 		}
336 336
 
337
-		if ( null !== $this->language ) {
337
+		if (null !== $this->language) {
338 338
 			$object->language = $this->language;
339 339
 		}
340 340
 
341 341
 		$object->merchantReturnURL = $this->merchant_return_url;
342 342
 
343
-		if ( null !== $this->payment_brand ) {
343
+		if (null !== $this->payment_brand) {
344 344
 			$object->paymentBrand = $this->payment_brand;
345 345
 		}
346 346
 
347
-		if ( null !== $this->payment_brand_force ) {
347
+		if (null !== $this->payment_brand_force) {
348 348
 			$object->paymentBrandForce = $this->payment_brand_force;
349 349
 		}
350 350
 
@@ -359,38 +359,38 @@  discard block
 block discarded – undo
359 359
 	 * @param array $fields Fields.
360 360
 	 * @return array
361 361
 	 */
362
-	public function get_signature_fields( $fields = array() ) {
363
-		$fields[] = $this->timestamp->format( DATE_ATOM );
362
+	public function get_signature_fields($fields = array()) {
363
+		$fields[] = $this->timestamp->format(DATE_ATOM);
364 364
 		$fields[] = $this->merchant_order_id;
365 365
 
366
-		$fields = $this->amount->get_signature_fields( $fields );
366
+		$fields = $this->amount->get_signature_fields($fields);
367 367
 
368 368
 		$fields[] = $this->language;
369 369
 		$fields[] = $this->description;
370 370
 		$fields[] = $this->merchant_return_url;
371 371
 
372
-		if ( null !== $this->order_items ) {
373
-			$fields = $this->order_items->get_signature_fields( $fields );
372
+		if (null !== $this->order_items) {
373
+			$fields = $this->order_items->get_signature_fields($fields);
374 374
 		}
375 375
 
376
-		if ( null !== $this->shipping_detail ) {
377
-			$fields = $this->shipping_detail->get_signature_fields( $fields );
376
+		if (null !== $this->shipping_detail) {
377
+			$fields = $this->shipping_detail->get_signature_fields($fields);
378 378
 		}
379 379
 
380
-		if ( null !== $this->payment_brand ) {
380
+		if (null !== $this->payment_brand) {
381 381
 			$fields[] = $this->payment_brand;
382 382
 		}
383 383
 
384
-		if ( null !== $this->payment_brand_force ) {
384
+		if (null !== $this->payment_brand_force) {
385 385
 			$fields[] = $this->payment_brand_force;
386 386
 		}
387 387
 
388
-		if ( null !== $this->customer_information ) {
389
-			$fields = $this->customer_information->get_signature_fields( $fields );
388
+		if (null !== $this->customer_information) {
389
+			$fields = $this->customer_information->get_signature_fields($fields);
390 390
 		}
391 391
 
392
-		if ( null !== $this->billing_detail ) {
393
-			$fields = $this->billing_detail->get_signature_fields( $fields );
392
+		if (null !== $this->billing_detail) {
393
+			$fields = $this->billing_detail->get_signature_fields($fields);
394 394
 		}
395 395
 
396 396
 		return $fields;
Please login to merge, or discard this patch.
src/Gateway.php 1 patch
Spacing   +76 added lines, -76 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,71 +78,71 @@  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
 		// New order.
88 88
 		$order = new Order(
89 89
 			$merchant_order_id,
90
-			MoneyTransformer::transform( $payment->get_total_amount() ),
90
+			MoneyTransformer::transform($payment->get_total_amount()),
91 91
 			$payment->get_return_url()
92 92
 		);
93 93
 
94 94
 		// Shipping address.
95
-		$order->set_shipping_detail( AddressTransformer::transform( $payment->get_shipping_address() ) );
95
+		$order->set_shipping_detail(AddressTransformer::transform($payment->get_shipping_address()));
96 96
 
97 97
 		// Billing address.
98
-		$order->set_billing_detail( AddressTransformer::transform( $payment->get_billing_address() ) );
98
+		$order->set_billing_detail(AddressTransformer::transform($payment->get_billing_address()));
99 99
 
100 100
 		// Customer information.
101 101
 		$customer = $payment->get_customer();
102 102
 
103
-		if ( null !== $customer ) {
104
-			$order->set_language( $customer->get_language() );
103
+		if (null !== $customer) {
104
+			$order->set_language($customer->get_language());
105 105
 
106 106
 			$customer_information = new CustomerInformation();
107 107
 
108
-			$customer_information->set_email_address( $customer->get_email() );
109
-			$customer_information->set_date_of_birth( $customer->get_birth_date() );
110
-			$customer_information->set_gender( $customer->get_gender() );
111
-			$customer_information->set_telephone_number( $customer->get_phone() );
108
+			$customer_information->set_email_address($customer->get_email());
109
+			$customer_information->set_date_of_birth($customer->get_birth_date());
110
+			$customer_information->set_gender($customer->get_gender());
111
+			$customer_information->set_telephone_number($customer->get_phone());
112 112
 
113
-			$order->set_customer_information( $customer_information );
113
+			$order->set_customer_information($customer_information);
114 114
 		}
115 115
 
116 116
 		// Payment brand.
117
-		$payment_brand = PaymentBrands::transform( $payment->get_method() );
117
+		$payment_brand = PaymentBrands::transform($payment->get_method());
118 118
 
119
-		$order->set_payment_brand( $payment_brand );
119
+		$order->set_payment_brand($payment_brand);
120 120
 
121
-		if ( null !== $payment_brand ) {
121
+		if (null !== $payment_brand) {
122 122
 			// Payment brand force should only be set if payment brand is not empty.
123
-			$order->set_payment_brand_force( PaymentBrandForce::FORCE_ONCE );
123
+			$order->set_payment_brand_force(PaymentBrandForce::FORCE_ONCE);
124 124
 		}
125 125
 
126 126
 		// Description.
127
-		$order->set_description( substr( $payment->get_description(), 0, 35 ) );
127
+		$order->set_description(substr($payment->get_description(), 0, 35));
128 128
 
129 129
 		// Lines.
130
-		if ( null !== $payment->get_lines() ) {
130
+		if (null !== $payment->get_lines()) {
131 131
 			$order_items = $order->new_items();
132 132
 
133
-			foreach ( $payment->get_lines() as $line ) {
133
+			foreach ($payment->get_lines() as $line) {
134 134
 				$item = $order_items->new_item(
135 135
 					$line->get_name(),
136 136
 					$line->get_quantity(),
137
-					MoneyTransformer::transform( $line->get_total_amount() ),
138
-					ProductCategories::transform( $line->get_type() )
137
+					MoneyTransformer::transform($line->get_total_amount()),
138
+					ProductCategories::transform($line->get_type())
139 139
 				);
140 140
 
141
-				$item->set_id( $line->get_id() );
142
-				$item->set_description( $line->get_description() );
141
+				$item->set_id($line->get_id());
142
+				$item->set_description($line->get_description());
143 143
 
144
-				if ( null !== $line->get_tax_amount() ) {
145
-					$item->set_tax( MoneyTransformer::transform( $line->get_tax_amount() ) );
144
+				if (null !== $line->get_tax_amount()) {
145
+					$item->set_tax(MoneyTransformer::transform($line->get_tax_amount()));
146 146
 				}
147 147
 			}
148 148
 		}
@@ -151,27 +151,27 @@  discard block
 block discarded – undo
151 151
 		$this->maybe_update_access_token();
152 152
 
153 153
 		// Handle errors.
154
-		if ( $this->get_client_error() ) {
154
+		if ($this->get_client_error()) {
155 155
 			return;
156 156
 		}
157 157
 
158 158
 		// Announce order.
159
-		$response = $this->client->order_announce( $this->config, $order );
159
+		$response = $this->client->order_announce($this->config, $order);
160 160
 
161 161
 		// Handle errors.
162
-		if ( $this->get_client_error() ) {
162
+		if ($this->get_client_error()) {
163 163
 			return;
164 164
 		}
165 165
 
166
-		if ( false === $response ) {
166
+		if (false === $response) {
167 167
 			return;
168 168
 		}
169 169
 
170
-		if ( ! $response->is_valid( $this->config->signing_key ) ) {
170
+		if ( ! $response->is_valid($this->config->signing_key)) {
171 171
 			return;
172 172
 		}
173 173
 
174
-		$payment->set_action_url( $response->get_redirect_url() );
174
+		$payment->set_action_url($response->get_redirect_url());
175 175
 	}
176 176
 
177 177
 	/**
@@ -179,48 +179,48 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param Payment $payment Payment.
181 181
 	 */
182
-	public function update_status( Payment $payment ) {
183
-		if ( ! ReturnParameters::contains( $_GET ) ) { // WPCS: CSRF ok.
182
+	public function update_status(Payment $payment) {
183
+		if ( ! ReturnParameters::contains($_GET)) { // WPCS: CSRF ok.
184 184
 			return;
185 185
 		}
186 186
 
187
-		$parameters = ReturnParameters::from_array( $_GET ); // WPCS: CSRF ok.
187
+		$parameters = ReturnParameters::from_array($_GET); // WPCS: CSRF ok.
188 188
 
189 189
 		// Note.
190 190
 		$note_values = array(
191 191
 			'order_id'  => $parameters->get_order_id(),
192 192
 			'status'    => $parameters->get_status(),
193 193
 			'signature' => $parameters->get_signature(),
194
-			'valid'     => $parameters->is_valid( $this->config->signing_key ) ? 'true' : 'false',
194
+			'valid'     => $parameters->is_valid($this->config->signing_key) ? 'true' : 'false',
195 195
 		);
196 196
 
197 197
 		$note = '';
198 198
 
199 199
 		$note .= '<p>';
200
-		$note .= __( 'OmniKassa 2.0 return URL requested:', 'pronamic_ideal' );
200
+		$note .= __('OmniKassa 2.0 return URL requested:', 'pronamic_ideal');
201 201
 		$note .= '</p>';
202 202
 
203 203
 		$note .= '<dl>';
204 204
 
205
-		foreach ( $note_values as $key => $value ) {
206
-			$note .= sprintf( '<dt>%s</dt>', esc_html( $key ) );
207
-			$note .= sprintf( '<dd>%s</dd>', esc_html( $value ) );
205
+		foreach ($note_values as $key => $value) {
206
+			$note .= sprintf('<dt>%s</dt>', esc_html($key));
207
+			$note .= sprintf('<dd>%s</dd>', esc_html($value));
208 208
 		}
209 209
 
210 210
 		$note .= '</dl>';
211 211
 
212
-		$payment->add_note( $note );
212
+		$payment->add_note($note);
213 213
 
214 214
 		// Validate.
215
-		if ( ! $parameters->is_valid( $this->config->signing_key ) ) {
215
+		if ( ! $parameters->is_valid($this->config->signing_key)) {
216 216
 			return;
217 217
 		}
218 218
 
219 219
 		// Status.
220
-		$pronamic_status = Statuses::transform( $parameters->get_status() );
220
+		$pronamic_status = Statuses::transform($parameters->get_status());
221 221
 
222
-		if ( null !== $pronamic_status ) {
223
-			$payment->set_status( $pronamic_status );
222
+		if (null !== $pronamic_status) {
223
+			$payment->set_status($pronamic_status);
224 224
 		}
225 225
 	}
226 226
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return void
233 233
 	 */
234
-	public function handle_notification( Notification $notification ) {
235
-		if ( ! $notification->is_valid( $this->config->signing_key ) ) {
234
+	public function handle_notification(Notification $notification) {
235
+		if ( ! $notification->is_valid($this->config->signing_key)) {
236 236
 			return;
237 237
 		}
238 238
 
239
-		switch ( $notification->get_event_name() ) {
239
+		switch ($notification->get_event_name()) {
240 240
 			case 'merchant.order.status.changed':
241
-				$this->handle_merchant_order_status_changed( $notification );
241
+				$this->handle_merchant_order_status_changed($notification);
242 242
 		}
243 243
 	}
244 244
 
@@ -249,44 +249,44 @@  discard block
 block discarded – undo
249 249
 	 *
250 250
 	 * @return void
251 251
 	 */
252
-	private function handle_merchant_order_status_changed( Notification $notification ) {
252
+	private function handle_merchant_order_status_changed(Notification $notification) {
253 253
 		do {
254
-			$order_results = $this->client->get_order_results( $notification->get_authentication() );
254
+			$order_results = $this->client->get_order_results($notification->get_authentication());
255 255
 
256
-			if ( ! $order_results || $order_results->is_valid( $this->config->signing_key ) ) {
256
+			if ( ! $order_results || $order_results->is_valid($this->config->signing_key)) {
257 257
 				return;
258 258
 			}
259 259
 
260
-			foreach ( $order_results as $order_result ) {
261
-				$payment = get_pronamic_payment_by_meta( '_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id() );
260
+			foreach ($order_results as $order_result) {
261
+				$payment = get_pronamic_payment_by_meta('_pronamic_payment_omnikassa_2_merchant_order_id', $order_result->get_merchant_order_id());
262 262
 
263
-				if ( empty( $payment ) ) {
263
+				if (empty($payment)) {
264 264
 					continue;
265 265
 				}
266 266
 
267
-				$payment->set_transaction_id( $order_result->get_omnikassa_order_id() );
267
+				$payment->set_transaction_id($order_result->get_omnikassa_order_id());
268 268
 
269
-				$pronamic_status = Statuses::transform( $order_result->get_order_status() );
269
+				$pronamic_status = Statuses::transform($order_result->get_order_status());
270 270
 
271
-				if ( null !== $pronamic_status ) {
272
-					$payment->set_status( $pronamic_status );
271
+				if (null !== $pronamic_status) {
272
+					$payment->set_status($pronamic_status);
273 273
 				}
274 274
 
275 275
 				// Note.
276 276
 				$note = '';
277 277
 
278 278
 				$note .= '<p>';
279
-				$note .= __( 'OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal' );
279
+				$note .= __('OmniKassa 2.0 webhook URL requested:', 'pronamic_ideal');
280 280
 				$note .= '</p>';
281 281
 				$note .= '<pre>';
282
-				$note .= wp_json_encode( $order_result->get_json(), JSON_PRETTY_PRINT );
282
+				$note .= wp_json_encode($order_result->get_json(), JSON_PRETTY_PRINT);
283 283
 				$note .= '</pre>';
284 284
 
285
-				$payment->add_note( $note );
285
+				$payment->add_note($note);
286 286
 
287 287
 				$payment->save();
288 288
 			}
289
-		} while ( $order_results->more_available() );
289
+		} while ($order_results->more_available());
290 290
 	}
291 291
 
292 292
 	/**
@@ -295,23 +295,23 @@  discard block
 block discarded – undo
295 295
 	 * @return void
296 296
 	 */
297 297
 	private function maybe_update_access_token() {
298
-		if ( $this->config->is_access_token_valid() ) {
298
+		if ($this->config->is_access_token_valid()) {
299 299
 			return;
300 300
 		}
301 301
 
302 302
 		$data = $this->client->get_access_token_data();
303 303
 
304
-		if ( ! is_object( $data ) ) {
304
+		if ( ! is_object($data)) {
305 305
 			return;
306 306
 		}
307 307
 
308
-		if ( isset( $data->token ) ) {
308
+		if (isset($data->token)) {
309 309
 			$this->config->access_token = $data->token;
310 310
 
311
-			update_post_meta( $this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token );
311
+			update_post_meta($this->config->post_id, '_pronamic_gateway_omnikassa_2_access_token', $data->token);
312 312
 		}
313 313
 
314
-		if ( isset( $data->validUntil ) ) {
314
+		if (isset($data->validUntil)) {
315 315
 			$this->config->access_token_valid_until = $data->validUntil;
316 316
 
317 317
 			update_post_meta(
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	private function get_client_error() {
331 331
 		$error = $this->client->get_error();
332 332
 
333
-		if ( is_wp_error( $error ) ) {
333
+		if (is_wp_error($error)) {
334 334
 			$this->error = $error;
335 335
 
336 336
 			return $error;
Please login to merge, or discard this patch.