Failed Conditions
Push — develop ( 163106...3a51c2 )
by Remco
19:25 queued 03:12
created
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 ( is_wp_error( $response ) ) {
157
+		if (is_wp_error($response)) {
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.