Completed
Push — feature/post-pay ( 4d62a9...853f37 )
by Remco
03:58
created
src/Client.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string $merchant_id  Merchant ID.
69 69
 	 * @param string $merchant_key Merchant key.
70 70
 	 */
71
-	public function __construct( $merchant_id, $merchant_key ) {
71
+	public function __construct($merchant_id, $merchant_key) {
72 72
 		$this->merchant_id  = $merchant_id;
73 73
 		$this->merchant_key = $merchant_key;
74 74
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @param boolean $test_mode True if test mode, false otherwise.
89 89
 	 */
90
-	public function set_test_mode( $test_mode ) {
90
+	public function set_test_mode($test_mode) {
91 91
 		$this->test_mode = $test_mode;
92 92
 	}
93 93
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @param array  $parameters Parameters.
99 99
 	 * @return string|WP_Error
100 100
 	 */
101
-	private function send_request( $method, array $parameters = array() ) {
101
+	private function send_request($method, array $parameters = array()) {
102 102
 		$url = self::API_URL . '/' . $method;
103 103
 
104 104
 		return Core_Util::remote_get_body(
@@ -117,31 +117,31 @@  discard block
 block discarded – undo
117 117
 	 * @param SimpleXMLElement $document Document.
118 118
 	 * @return WP_Error|Transaction|Error
119 119
 	 */
120
-	private function parse_document( SimpleXMLElement $document ) {
120
+	private function parse_document(SimpleXMLElement $document) {
121 121
 		$this->error = null;
122 122
 
123 123
 		$name = $document->getName();
124 124
 
125
-		switch ( $name ) {
125
+		switch ($name) {
126 126
 			case 'errorresponse':
127
-				$sisow_error = ErrorParser::parse( $document->error );
127
+				$sisow_error = ErrorParser::parse($document->error);
128 128
 
129
-				$this->error = new WP_Error( 'ideal_sisow_error', $sisow_error->message, $sisow_error );
129
+				$this->error = new WP_Error('ideal_sisow_error', $sisow_error->message, $sisow_error);
130 130
 
131 131
 				return $sisow_error;
132 132
 			case 'transactionrequest':
133
-				$transaction = TransactionParser::parse( $document->transaction );
133
+				$transaction = TransactionParser::parse($document->transaction);
134 134
 
135 135
 				return $transaction;
136 136
 			case 'statusresponse':
137
-				$transaction = TransactionParser::parse( $document->transaction );
137
+				$transaction = TransactionParser::parse($document->transaction);
138 138
 
139 139
 				return $transaction;
140 140
 			default:
141 141
 				return new WP_Error(
142 142
 					'ideal_sisow_error',
143 143
 					/* translators: %s: XML document element name */
144
-					sprintf( __( 'Unknwon Sisow message (%s)', 'pronamic_ideal' ), $name )
144
+					sprintf(__('Unknwon Sisow message (%s)', 'pronamic_ideal'), $name)
145 145
 				);
146 146
 		}
147 147
 	}
@@ -154,36 +154,36 @@  discard block
 block discarded – undo
154 154
 	public function get_directory() {
155 155
 		$directory = false;
156 156
 
157
-		if ( $this->test_mode ) {
158
-			$directory = array( '99' => __( 'Sisow Bank (test)', 'pronamic_ideal' ) );
157
+		if ($this->test_mode) {
158
+			$directory = array('99' => __('Sisow Bank (test)', 'pronamic_ideal'));
159 159
 		} else {
160 160
 			// Request.
161
-			$result = $this->send_request( RequestMethods::DIRECTORY_REQUEST );
161
+			$result = $this->send_request(RequestMethods::DIRECTORY_REQUEST);
162 162
 
163
-			if ( $result instanceof WP_Error ) {
163
+			if ($result instanceof WP_Error) {
164 164
 				$this->error = $result;
165 165
 
166 166
 				return $directory;
167 167
 			}
168 168
 
169 169
 			// XML.
170
-			$xml = Core_Util::simplexml_load_string( $result );
170
+			$xml = Core_Util::simplexml_load_string($result);
171 171
 
172
-			if ( is_wp_error( $xml ) ) {
172
+			if (is_wp_error($xml)) {
173 173
 				$this->error = $xml;
174 174
 
175 175
 				return $directory;
176 176
 			}
177 177
 
178 178
 			// Parse.
179
-			if ( $xml instanceof SimpleXMLElement ) {
179
+			if ($xml instanceof SimpleXMLElement) {
180 180
 				$directory = array();
181 181
 
182
-				foreach ( $xml->directory->issuer as $issuer ) {
182
+				foreach ($xml->directory->issuer as $issuer) {
183 183
 					$id   = (string) $issuer->issuerid;
184 184
 					$name = (string) $issuer->issuername;
185 185
 
186
-					$directory[ $id ] = $name;
186
+					$directory[$id] = $name;
187 187
 				}
188 188
 			}
189 189
 		}
@@ -197,34 +197,34 @@  discard block
 block discarded – undo
197 197
 	 * @param TransactionRequest $request Transaction request.
198 198
 	 * @return Transaction|false
199 199
 	 */
200
-	public function create_transaction( TransactionRequest $request ) {
200
+	public function create_transaction(TransactionRequest $request) {
201 201
 		$result = false;
202 202
 
203 203
 		// Request.
204
-		$request->sign( $this->merchant_key );
204
+		$request->sign($this->merchant_key);
205 205
 
206
-		$response = $this->send_request( RequestMethods::TRANSACTION_REQUEST, $request->get_parameters() );
206
+		$response = $this->send_request(RequestMethods::TRANSACTION_REQUEST, $request->get_parameters());
207 207
 
208
-		if ( $response instanceof WP_Error ) {
208
+		if ($response instanceof WP_Error) {
209 209
 			$this->error = $response;
210 210
 
211 211
 			return $result;
212 212
 		}
213 213
 
214 214
 		// XML.
215
-		$xml = Core_Util::simplexml_load_string( $response );
215
+		$xml = Core_Util::simplexml_load_string($response);
216 216
 
217
-		if ( $xml instanceof WP_Error ) {
217
+		if ($xml instanceof WP_Error) {
218 218
 			$this->error = $xml;
219 219
 
220 220
 			return $result;
221 221
 		}
222 222
 
223 223
 		// Parse.
224
-		if ( $xml instanceof SimpleXMLElement ) {
225
-			$message = $this->parse_document( $xml );
224
+		if ($xml instanceof SimpleXMLElement) {
225
+			$message = $this->parse_document($xml);
226 226
 
227
-			if ( $message instanceof Transaction ) {
227
+			if ($message instanceof Transaction) {
228 228
 				$result = $message;
229 229
 			}
230 230
 		}
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
 	 * @param StatusRequest $request Status request object.
239 239
 	 * @return Transaction|false
240 240
 	 */
241
-	public function get_status( StatusRequest $request ) {
241
+	public function get_status(StatusRequest $request) {
242 242
 		$status = false;
243 243
 
244 244
 		// Request.
245
-		$request->sign( $this->merchant_key );
245
+		$request->sign($this->merchant_key);
246 246
 
247
-		$result = $this->send_request( RequestMethods::STATUS_REQUEST, $request->get_parameters() );
247
+		$result = $this->send_request(RequestMethods::STATUS_REQUEST, $request->get_parameters());
248 248
 
249
-		if ( $result instanceof WP_Error ) {
249
+		if ($result instanceof WP_Error) {
250 250
 			$this->error = $result;
251 251
 
252 252
 			return $status;
253 253
 		}
254 254
 
255 255
 		// XML.
256
-		$xml = Core_Util::simplexml_load_string( $result );
256
+		$xml = Core_Util::simplexml_load_string($result);
257 257
 
258
-		if ( $xml instanceof WP_Error ) {
258
+		if ($xml instanceof WP_Error) {
259 259
 			$this->error = $xml;
260 260
 
261 261
 			return $status;
262 262
 		}
263 263
 
264 264
 		// Parse.
265
-		if ( $xml instanceof SimpleXMLElement ) {
266
-			$status = $this->parse_document( $xml );
265
+		if ($xml instanceof SimpleXMLElement) {
266
+			$status = $this->parse_document($xml);
267 267
 
268 268
 			return $status;
269 269
 		}
Please login to merge, or discard this patch.