Failed Conditions
Push — develop ( 1693b9...1d01be )
by Remco
03:49
created
src/PaymentBrands.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,8 +97,8 @@
 block discarded – undo
97 97
 	 * @param string $payment_method Payment method.
98 98
 	 * @return string|null
99 99
 	 */
100
-	public static function transform( $payment_method ) {
101
-		switch ( $payment_method ) {
100
+	public static function transform($payment_method) {
101
+		switch ($payment_method) {
102 102
 			case PaymentMethods::BANCONTACT:
103 103
 				return self::BANCONTACT;
104 104
 			case PaymentMethods::CREDIT_CARD:
Please login to merge, or discard this patch.
src/Order.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
 	 * @param Money  $amount               Amount.
152 152
 	 * @param string $merchant_return_url  Merchant return URL.
153 153
 	 */
154
-	public function __construct( $merchant_order_id, $amount, $merchant_return_url ) {
155
-		$this->timestamp           = date( DATE_ATOM );
154
+	public function __construct($merchant_order_id, $amount, $merchant_return_url) {
155
+		$this->timestamp           = date(DATE_ATOM);
156 156
 		$this->merchant_order_id   = $merchant_order_id;
157 157
 		$this->amount              = $amount;
158 158
 		$this->merchant_return_url = $merchant_return_url;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @param string $description Description.
165 165
 	 */
166
-	public function set_description( $description ) {
166
+	public function set_description($description) {
167 167
 		$this->description = $description;
168 168
 	}
169 169
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @param string $language Language.
174 174
 	 */
175
-	public function set_language( $language ) {
175
+	public function set_language($language) {
176 176
 		$this->language = $language;
177 177
 	}
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param string|null $payment_brand Payment brand.
183 183
 	 */
184
-	public function set_payment_brand( $payment_brand ) {
184
+	public function set_payment_brand($payment_brand) {
185 185
 		$this->payment_brand = $payment_brand;
186 186
 	}
187 187
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @param string $payment_brand_force Payment brand force.
192 192
 	 */
193
-	public function set_payment_brand_force( $payment_brand_force ) {
193
+	public function set_payment_brand_force($payment_brand_force) {
194 194
 		$this->payment_brand_force = $payment_brand_force;
195 195
 	}
196 196
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 		);
238 238
 
239 239
 		// Remove empty optional fields.
240
-		$optional = array_filter( $optional );
240
+		$optional = array_filter($optional);
241 241
 
242
-		return array_merge( $fields, $optional );
242
+		return array_merge($fields, $optional);
243 243
 	}
244 244
 }
Please login to merge, or discard this patch.
src/Client.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param string $url URL.
87 87
 	 */
88
-	public function set_url( $url ) {
88
+	public function set_url($url) {
89 89
 		$this->url = $url;
90 90
 	}
91 91
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param string $refresh_token Refresh token.
105 105
 	 */
106
-	public function set_refresh_token( $refresh_token ) {
106
+	public function set_refresh_token($refresh_token) {
107 107
 		$this->refresh_token = $refresh_token;
108 108
 	}
109 109
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @param string $signing_key Signing key.
123 123
 	 */
124
-	public function set_signing_key( $signing_key ) {
124
+	public function set_signing_key($signing_key) {
125 125
 		$this->signing_key = $signing_key;
126 126
 	}
127 127
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @param string      $token    Authorization token.
134 134
 	 * @param object|null $object   Object.
135 135
 	 */
136
-	private function request( $method, $endpoint, $token, $object = null ) {
136
+	private function request($method, $endpoint, $token, $object = null) {
137 137
 		// URL.
138 138
 		$url = $this->get_url() . $endpoint;
139 139
 
@@ -145,45 +145,45 @@  discard block
 block discarded – undo
145 145
 			),
146 146
 		);
147 147
 
148
-		if ( null !== $object ) {
148
+		if (null !== $object) {
149 149
 			$args['headers']['Content-Type'] = 'application/json';
150 150
 
151
-			$args['body'] = wp_json_encode( $object );
151
+			$args['body'] = wp_json_encode($object);
152 152
 		}
153 153
 
154 154
 		// Request.
155
-		$response = wp_remote_request( $url, $args );
155
+		$response = wp_remote_request($url, $args);
156 156
 
157
-		if ( $response instanceof WP_Error ) {
157
+		if ($response instanceof WP_Error) {
158 158
 			$this->error = $response;
159 159
 
160
-			$this->error->add( 'omnikassa_2_error', 'HTTP Request Failed' );
160
+			$this->error->add('omnikassa_2_error', 'HTTP Request Failed');
161 161
 
162 162
 			return false;
163 163
 		}
164 164
 
165 165
 		// Body.
166
-		$body = wp_remote_retrieve_body( $response );
166
+		$body = wp_remote_retrieve_body($response);
167 167
 
168
-		$data = json_decode( $body );
168
+		$data = json_decode($body);
169 169
 
170
-		if ( ! is_object( $data ) ) {
171
-			$this->error = new WP_Error( 'omnikassa_2_error', 'Could not parse response.', $data );
170
+		if ( ! is_object($data)) {
171
+			$this->error = new WP_Error('omnikassa_2_error', 'Could not parse response.', $data);
172 172
 
173 173
 			return false;
174 174
 		}
175 175
 
176 176
 		// Error.
177
-		if ( isset( $data->errorCode ) ) {
177
+		if (isset($data->errorCode)) {
178 178
 			$message = 'Unknown error.';
179 179
 
180
-			if ( isset( $data->consumerMessage ) ) {
180
+			if (isset($data->consumerMessage)) {
181 181
 				$message = $data->consumerMessage;
182
-			} elseif ( isset( $data->errorMessage ) ) {
182
+			} elseif (isset($data->errorMessage)) {
183 183
 				$message = $data->errorMessage;
184 184
 			}
185 185
 
186
-			$this->error = new WP_Error( 'omnikassa_2_error', $message, $data );
186
+			$this->error = new WP_Error('omnikassa_2_error', $message, $data);
187 187
 
188 188
 			return false;
189 189
 		}
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return object|false
199 199
 	 */
200 200
 	public function get_access_token_data() {
201
-		return $this->request( 'GET', 'gatekeeper/refresh', $this->get_refresh_token() );
201
+		return $this->request('GET', 'gatekeeper/refresh', $this->get_refresh_token());
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 	 * @param Order  $order  Order.
209 209
 	 * @return object|bool
210 210
 	 */
211
-	public function order_announce( $config, Order $order ) {
211
+	public function order_announce($config, Order $order) {
212 212
 		$object = $order->get_json();
213 213
 
214
-		$object->signature = Security::get_signature( $order, $config->signing_key );
214
+		$object->signature = Security::get_signature($order, $config->signing_key);
215 215
 
216
-		return $this->request( 'POST', 'order/server/api/order', $config->access_token, $object );
216
+		return $this->request('POST', 'order/server/api/order', $config->access_token, $object);
217 217
 	}
218 218
 
219 219
 	/**
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return OrderResults|false
225 225
 	 */
226
-	public function get_order_results( $notification_token ) {
227
-		$result = $this->request( 'GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token );
226
+	public function get_order_results($notification_token) {
227
+		$result = $this->request('GET', 'order/server/api/events/results/merchant.order.status.changed', $notification_token);
228 228
 
229
-		if ( ! is_object( $result ) ) {
229
+		if ( ! is_object($result)) {
230 230
 			return false;
231 231
 		}
232 232
 
233
-		return OrderResults::from_object( $result );
233
+		return OrderResults::from_object($result);
234 234
 	}
235 235
 }
Please login to merge, or discard this patch.
src/Security.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -25,26 +25,26 @@  discard block
 block discarded – undo
25 25
 	 * @param string   $signing_key Signing Key.
26 26
 	 * @return string|null
27 27
 	 */
28
-	public static function get_signature( Signable $signable, $signing_key ) {
28
+	public static function get_signature(Signable $signable, $signing_key) {
29 29
 		$data = $signable->get_signature_data();
30 30
 
31
-		if ( empty( $data ) ) {
31
+		if (empty($data)) {
32 32
 			return null;
33 33
 		}
34 34
 
35
-		if ( empty( $signing_key ) ) {
35
+		if (empty($signing_key)) {
36 36
 			return null;
37 37
 		}
38 38
 
39
-		$decoded_signing_key = base64_decode( $signing_key );
39
+		$decoded_signing_key = base64_decode($signing_key);
40 40
 
41
-		if ( false === $decoded_signing_key ) {
41
+		if (false === $decoded_signing_key) {
42 42
 			return null;
43 43
 		}
44 44
 
45 45
 		$signature = hash_hmac(
46 46
 			'sha512',
47
-			implode( ',', $data ),
47
+			implode(',', $data),
48 48
 			$decoded_signing_key
49 49
 		);
50 50
 
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 * @param string $signature_b Signature B.
59 59
 	 * @return bool True if valid, false otherwise.
60 60
 	 */
61
-	public static function validate_signature( $signature_a, $signature_b ) {
62
-		if ( empty( $signature_a ) || empty( $signature_b ) ) {
61
+	public static function validate_signature($signature_a, $signature_b) {
62
+		if (empty($signature_a) || empty($signature_b)) {
63 63
 			// Empty signature string or null from calculation.
64 64
 			return false;
65 65
 		}
66 66
 
67
-		return ( 0 === strcasecmp( $signature_a, $signature_b ) );
67
+		return (0 === strcasecmp($signature_a, $signature_b));
68 68
 	}
69 69
 }
Please login to merge, or discard this patch.
src/Message.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param string $signature Signature.
41 41
 	 */
42
-	protected function set_signature( $signature ) {
42
+	protected function set_signature($signature) {
43 43
 		$this->signature = $signature;
44 44
 	}
45 45
 
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 * @param string $signing_key Signing key.
50 50
 	 * @return bool True if valid, false otherwise.
51 51
 	 */
52
-	public function is_valid( $signing_key ) {
53
-		$signature = Security::get_signature( $this, $signing_key );
52
+	public function is_valid($signing_key) {
53
+		$signature = Security::get_signature($this, $signing_key);
54 54
 
55
-		if ( empty( $signature ) ) {
55
+		if (empty($signature)) {
56 56
 			return false;
57 57
 		}
58 58
 
59
-		return Security::validate_signature( $signature, $this->get_signature() );
59
+		return Security::validate_signature($signature, $this->get_signature());
60 60
 	}
61 61
 }
Please login to merge, or discard this patch.
src/WebhookListener.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 	 * Listen to OmniKassa 2.0 webhook requests.
26 26
 	 */
27 27
 	public static function listen() {
28
-		if ( ! filter_has_var( INPUT_GET, 'omnikassa2_webhook' ) ) {
28
+		if ( ! filter_has_var(INPUT_GET, 'omnikassa2_webhook')) {
29 29
 			return;
30 30
 		}
31 31
 
32
-		$json = file_get_contents( 'php://input' );
32
+		$json = file_get_contents('php://input');
33 33
 
34
-		if ( false === $json ) {
34
+		if (false === $json) {
35 35
 			return;
36 36
 		}
37 37
 
38
-		$notification = Notification::from_json( $json );
38
+		$notification = Notification::from_json($json);
39 39
 
40 40
 		$query = new \WP_Query(
41 41
 			array(
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 			)
52 52
 		);
53 53
 
54
-		foreach ( $query->posts as $post ) {
55
-			$gateway = Plugin::get_gateway( $post->ID );
54
+		foreach ($query->posts as $post) {
55
+			$gateway = Plugin::get_gateway($post->ID);
56 56
 
57
-			if ( $gateway instanceof Gateway ) {
58
-				$gateway->handle_notification( $notification );
57
+			if ($gateway instanceof Gateway) {
58
+				$gateway->handle_notification($notification);
59 59
 			}
60 60
 		}
61 61
 	}
Please login to merge, or discard this patch.