Passed
Push — master ( 9fd382...ca8ec7 )
by Patrik
44s queued 12s
created
includes/class-wpinv-session.php 4 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,8 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @since 1.0.0
165 165
 	 *
166 166
 	 * @param string|array $key Session key.
167
-	 * @param integer $value Session variable.
168
-	 * @return string Session variable.
167
+	 * @return boolean Session variable.
169 168
 	 */
170 169
 	public function un_set( $key ) {
171 170
 		if ( empty( $key ) ) {
@@ -201,8 +200,7 @@  discard block
 block discarded – undo
201 200
 	 * @since 1.0.0
202 201
 	 *
203 202
 	 * @param string $key Session key.
204
-	 * @param integer $value Session variable.
205
-	 * @return string Session variable.
203
+	 * @return boolean Session variable.
206 204
 	 */
207 205
 	public function is_set( $key ) {
208 206
 		$key = sanitize_key( $key );
Please login to merge, or discard this patch.
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -8,291 +8,291 @@
 block discarded – undo
8 8
  * @since 1.0.0
9 9
  */
10 10
 class WPInv_Session {
11
-	/**
12
-	 * Holds our session data.
13
-	 *
14
-	 * @var array
15
-	 * @access private
16
-	 * @since 1.0.0
17
-	 */
18
-	private $session;
19
-
20
-	/**
21
-	 * Whether to use PHP $_SESSION or WP_Session.
22
-	 *
23
-	 * @var bool
24
-	 * @access private
25
-	 * @since 1.0.0
26
-	 */
27
-	private $use_php_sessions = false;
28
-
29
-	/**
30
-	 * Session index prefix.
31
-	 *
32
-	 * @var string
33
-	 * @access private
34
-	 * @since 1.0.0
35
-	 */
36
-	private $prefix = '';
37
-
38
-	/**
39
-	 * Get things started.
40
-	 *
41
-	 * Defines our WP_Session constants, includes the necessary libraries and
42
-	 * retrieves the WP Session instance.
43
-	 *
44
-	 * @since 1.0.0
45
-	 */
46
-	public function __construct() {
47
-		$this->use_php_sessions = $this->use_php_sessions();
48
-
49
-		if ( $this->use_php_sessions ) {
50
-			if ( is_multisite() ) {
51
-				$this->prefix = '_' . get_current_blog_id();
52
-			}
53
-
54
-			// Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant)
55
-			add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
56
-		} else {
57
-			// Use WP_Session (default)
58
-			if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
-				define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' );
60
-			}
61
-
62
-			if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
63
-				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php';
64
-			}
11
+    /**
12
+     * Holds our session data.
13
+     *
14
+     * @var array
15
+     * @access private
16
+     * @since 1.0.0
17
+     */
18
+    private $session;
19
+
20
+    /**
21
+     * Whether to use PHP $_SESSION or WP_Session.
22
+     *
23
+     * @var bool
24
+     * @access private
25
+     * @since 1.0.0
26
+     */
27
+    private $use_php_sessions = false;
28
+
29
+    /**
30
+     * Session index prefix.
31
+     *
32
+     * @var string
33
+     * @access private
34
+     * @since 1.0.0
35
+     */
36
+    private $prefix = '';
37
+
38
+    /**
39
+     * Get things started.
40
+     *
41
+     * Defines our WP_Session constants, includes the necessary libraries and
42
+     * retrieves the WP Session instance.
43
+     *
44
+     * @since 1.0.0
45
+     */
46
+    public function __construct() {
47
+        $this->use_php_sessions = $this->use_php_sessions();
48
+
49
+        if ( $this->use_php_sessions ) {
50
+            if ( is_multisite() ) {
51
+                $this->prefix = '_' . get_current_blog_id();
52
+            }
53
+
54
+            // Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant)
55
+            add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
56
+        } else {
57
+            // Use WP_Session (default)
58
+            if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
+                define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' );
60
+            }
61
+
62
+            if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
63
+                require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php';
64
+            }
65 65
             
66
-			if ( !class_exists( 'WP_Session_Utils' ) ) {
67
-				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php';
68
-			}
66
+            if ( !class_exists( 'WP_Session_Utils' ) ) {
67
+                require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php';
68
+            }
69 69
             
70
-			if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) {
71
-				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php';
72
-			}
73
-
74
-			if ( !class_exists( 'WP_Session' ) ) {
75
-				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php';
76
-				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php';
77
-			}
78
-
79
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
80
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
81
-		}
82
-
83
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
84
-			add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
85
-		} else {
86
-			add_action( 'init', array( $this, 'init' ), -1 );
87
-		}
88
-	}
89
-
90
-	/**
91
-	 * Setup the WP_Session instance.
92
-	 *
93
-	 * @access public
94
-	 * @since 1.0.0
95
-	 * @return void
96
-	 */
97
-	public function init() {
98
-		if ( $this->use_php_sessions ) {
99
-			$this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array();
100
-		} else {
101
-			$this->session = WP_Session::get_instance();
102
-		}
103
-
104
-		return $this->session;
105
-	}
106
-
107
-	/**
108
-	 * Retrieve session ID.
109
-	 *
110
-	 * @access public
111
-	 * @since 1.0.0
112
-	 * @return string Session ID
113
-	 */
114
-	public function get_id() {
115
-		if ( $this->use_php_sessions ) {
116
-			$session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL;
117
-		} else {
118
-			$session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL;
119
-		}
120
-		return $session_id;
121
-	}
122
-
123
-	/**
124
-	 * Retrieve a session variable.
125
-	 *
126
-	 * @access public
127
-	 * @since 1.0.0
128
-	 * @param string $key Session key
129
-	 * @return string Session variable
130
-	 */
131
-	public function get( $key ) {
132
-		$key = sanitize_key( $key );
133
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
134
-	}
135
-
136
-	/**
137
-	 * Set a session variable
138
-	 *
139
-	 * @since 1.0.0
140
-	 *
141
-	 * @param string $key Session key
142
-	 * @param integer $value Session variable
143
-	 * @return string Session variable
144
-	 */
145
-	public function set( $key, $value ) {
146
-		$key = sanitize_key( $key );
147
-
148
-		if ( is_array( $value ) ) {
149
-			$this->session[ $key ] = maybe_serialize( $value );
150
-		} else {
151
-			$this->session[ $key ] = $value;
152
-		}
153
-
154
-		if ( $this->use_php_sessions ) {
155
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
156
-		}
157
-
158
-		return $this->session[ $key ];
159
-	}
70
+            if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) {
71
+                require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php';
72
+            }
73
+
74
+            if ( !class_exists( 'WP_Session' ) ) {
75
+                require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php';
76
+                require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php';
77
+            }
78
+
79
+            add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
80
+            add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
81
+        }
82
+
83
+        if ( empty( $this->session ) && ! $this->use_php_sessions ) {
84
+            add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
85
+        } else {
86
+            add_action( 'init', array( $this, 'init' ), -1 );
87
+        }
88
+    }
89
+
90
+    /**
91
+     * Setup the WP_Session instance.
92
+     *
93
+     * @access public
94
+     * @since 1.0.0
95
+     * @return void
96
+     */
97
+    public function init() {
98
+        if ( $this->use_php_sessions ) {
99
+            $this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array();
100
+        } else {
101
+            $this->session = WP_Session::get_instance();
102
+        }
103
+
104
+        return $this->session;
105
+    }
106
+
107
+    /**
108
+     * Retrieve session ID.
109
+     *
110
+     * @access public
111
+     * @since 1.0.0
112
+     * @return string Session ID
113
+     */
114
+    public function get_id() {
115
+        if ( $this->use_php_sessions ) {
116
+            $session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL;
117
+        } else {
118
+            $session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL;
119
+        }
120
+        return $session_id;
121
+    }
122
+
123
+    /**
124
+     * Retrieve a session variable.
125
+     *
126
+     * @access public
127
+     * @since 1.0.0
128
+     * @param string $key Session key
129
+     * @return string Session variable
130
+     */
131
+    public function get( $key ) {
132
+        $key = sanitize_key( $key );
133
+        return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
134
+    }
135
+
136
+    /**
137
+     * Set a session variable
138
+     *
139
+     * @since 1.0.0
140
+     *
141
+     * @param string $key Session key
142
+     * @param integer $value Session variable
143
+     * @return string Session variable
144
+     */
145
+    public function set( $key, $value ) {
146
+        $key = sanitize_key( $key );
147
+
148
+        if ( is_array( $value ) ) {
149
+            $this->session[ $key ] = maybe_serialize( $value );
150
+        } else {
151
+            $this->session[ $key ] = $value;
152
+        }
153
+
154
+        if ( $this->use_php_sessions ) {
155
+            $_SESSION['wpi' . $this->prefix ] = $this->session;
156
+        }
157
+
158
+        return $this->session[ $key ];
159
+    }
160 160
 	
161
-	/**
162
-	 * Unset a session variable.
163
-	 *
164
-	 * @since 1.0.0
165
-	 *
166
-	 * @param string|array $key Session key.
167
-	 * @param integer $value Session variable.
168
-	 * @return string Session variable.
169
-	 */
170
-	public function un_set( $key ) {
171
-		if ( empty( $key ) ) {
172
-			return false;
173
-		}
161
+    /**
162
+     * Unset a session variable.
163
+     *
164
+     * @since 1.0.0
165
+     *
166
+     * @param string|array $key Session key.
167
+     * @param integer $value Session variable.
168
+     * @return string Session variable.
169
+     */
170
+    public function un_set( $key ) {
171
+        if ( empty( $key ) ) {
172
+            return false;
173
+        }
174 174
 		
175
-		if ( is_array( $key ) ) {
176
-			foreach ($key as $index) {
177
-				$index = sanitize_key( $index );
175
+        if ( is_array( $key ) ) {
176
+            foreach ($key as $index) {
177
+                $index = sanitize_key( $index );
178 178
 			
179
-				if ( $index && isset( $this->session[ $index ] ) ) {
180
-					unset( $this->session[ $index ] );
181
-				}
182
-			}
183
-		} else {
184
-			$key = sanitize_key( $key );
179
+                if ( $index && isset( $this->session[ $index ] ) ) {
180
+                    unset( $this->session[ $index ] );
181
+                }
182
+            }
183
+        } else {
184
+            $key = sanitize_key( $key );
185 185
 			
186
-			if ( isset( $this->session[ $key ] ) ) {
187
-				unset( $this->session[ $key ] );
188
-			}
189
-		}
186
+            if ( isset( $this->session[ $key ] ) ) {
187
+                unset( $this->session[ $key ] );
188
+            }
189
+        }
190 190
 
191
-		if ( $this->use_php_sessions ) {
192
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
193
-		}
191
+        if ( $this->use_php_sessions ) {
192
+            $_SESSION['wpi' . $this->prefix ] = $this->session;
193
+        }
194 194
 
195
-		return true;
196
-	}
195
+        return true;
196
+    }
197 197
 	
198
-	/**
199
-	 * Check a session variable is set or not.
200
-	 *
201
-	 * @since 1.0.0
202
-	 *
203
-	 * @param string $key Session key.
204
-	 * @param integer $value Session variable.
205
-	 * @return string Session variable.
206
-	 */
207
-	public function is_set( $key ) {
208
-		$key = sanitize_key( $key );
198
+    /**
199
+     * Check a session variable is set or not.
200
+     *
201
+     * @since 1.0.0
202
+     *
203
+     * @param string $key Session key.
204
+     * @param integer $value Session variable.
205
+     * @return string Session variable.
206
+     */
207
+    public function is_set( $key ) {
208
+        $key = sanitize_key( $key );
209 209
 		
210
-		if ( empty( $key ) ) {
211
-			return false;
212
-		}
213
-
214
-		if ( isset( $this->session[ $key ] ) ) {
215
-			return true;
216
-		}
217
-
218
-		return false;
219
-	}
220
-
221
-	/**
222
-	 * Force the cookie expiration variant time to 23 hours
223
-	 *
224
-	 * @access public
225
-	 * @since 1.0.0
226
-	 * @param int $exp Default expiration (1 hour)
227
-	 * @return int
228
-	 */
229
-	public function set_expiration_variant_time( $exp ) {
230
-		return ( 30 * 60 * 23 );
231
-	}
232
-
233
-	/**
234
-	 * Force the cookie expiration time to 24 hours
235
-	 *
236
-	 * @access public
237
-	 * @since 1.0.0
238
-	 * @param int $exp Default expiration (1 hour)
239
-	 * @return int
240
-	 */
241
-	public function set_expiration_time( $exp ) {
242
-		return ( 30 * 60 * 24 );
243
-	}
244
-
245
-	/**
246
-	 * Starts a new session if one hasn't started yet.
247
-	 *
248
-	 * @return boolean
249
-	 * Checks to see if the server supports PHP sessions
250
-	 * or if the WPINV_USE_PHP_SESSIONS constant is defined
251
-	 *
252
-	 * @access public
253
-	 * @since 1.0.0
254
-	 * @return boolean $ret True if we are using PHP sessions, false otherwise
255
-	 */
256
-	public function use_php_sessions() {
257
-		$ret = false;
258
-
259
-		// If the database variable is already set, no need to run autodetection
260
-		$wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' );
261
-
262
-		if (!$wpinv_use_php_sessions ) {
263
-			// Attempt to detect if the server supports PHP sessions
264
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
265
-				$this->set( 'wpinv_use_php_sessions', 1 );
210
+        if ( empty( $key ) ) {
211
+            return false;
212
+        }
213
+
214
+        if ( isset( $this->session[ $key ] ) ) {
215
+            return true;
216
+        }
217
+
218
+        return false;
219
+    }
220
+
221
+    /**
222
+     * Force the cookie expiration variant time to 23 hours
223
+     *
224
+     * @access public
225
+     * @since 1.0.0
226
+     * @param int $exp Default expiration (1 hour)
227
+     * @return int
228
+     */
229
+    public function set_expiration_variant_time( $exp ) {
230
+        return ( 30 * 60 * 23 );
231
+    }
232
+
233
+    /**
234
+     * Force the cookie expiration time to 24 hours
235
+     *
236
+     * @access public
237
+     * @since 1.0.0
238
+     * @param int $exp Default expiration (1 hour)
239
+     * @return int
240
+     */
241
+    public function set_expiration_time( $exp ) {
242
+        return ( 30 * 60 * 24 );
243
+    }
244
+
245
+    /**
246
+     * Starts a new session if one hasn't started yet.
247
+     *
248
+     * @return boolean
249
+     * Checks to see if the server supports PHP sessions
250
+     * or if the WPINV_USE_PHP_SESSIONS constant is defined
251
+     *
252
+     * @access public
253
+     * @since 1.0.0
254
+     * @return boolean $ret True if we are using PHP sessions, false otherwise
255
+     */
256
+    public function use_php_sessions() {
257
+        $ret = false;
258
+
259
+        // If the database variable is already set, no need to run autodetection
260
+        $wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' );
261
+
262
+        if (!$wpinv_use_php_sessions ) {
263
+            // Attempt to detect if the server supports PHP sessions
264
+            if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
265
+                $this->set( 'wpinv_use_php_sessions', 1 );
266 266
 				
267
-				if ( $this->get( 'wpinv_use_php_sessions' ) ) {
268
-					$ret = true;
269
-
270
-					// Set the database option
271
-					update_option( 'wpinv_use_php_sessions', true );
272
-				}
273
-			}
274
-		} else {
275
-			$ret = $wpinv_use_php_sessions;
276
-		}
277
-
278
-		// Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant
279
-		if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) {
280
-			$ret = true;
281
-		} else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) {
282
-			$ret = false;
283
-		}
284
-
285
-		return (bool) apply_filters( 'wpinv_use_php_sessions', $ret );
286
-	}
287
-
288
-	/**
289
-	 * Starts a new session if one hasn't started yet.
290
-	 */
291
-	public function maybe_start_session() {
292
-		if ( !session_id() && !headers_sent() ) {
293
-			session_start();
294
-		}
295
-	}
267
+                if ( $this->get( 'wpinv_use_php_sessions' ) ) {
268
+                    $ret = true;
269
+
270
+                    // Set the database option
271
+                    update_option( 'wpinv_use_php_sessions', true );
272
+                }
273
+            }
274
+        } else {
275
+            $ret = $wpinv_use_php_sessions;
276
+        }
277
+
278
+        // Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant
279
+        if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) {
280
+            $ret = true;
281
+        } else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) {
282
+            $ret = false;
283
+        }
284
+
285
+        return (bool) apply_filters( 'wpinv_use_php_sessions', $ret );
286
+    }
287
+
288
+    /**
289
+     * Starts a new session if one hasn't started yet.
290
+     */
291
+    public function maybe_start_session() {
292
+        if ( !session_id() && !headers_sent() ) {
293
+            session_start();
294
+        }
295
+    }
296 296
 }
297 297
 
298 298
 global $wpi_session;
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 /**
6 6
  * WPInv_Session Class.
@@ -46,44 +46,44 @@  discard block
 block discarded – undo
46 46
 	public function __construct() {
47 47
 		$this->use_php_sessions = $this->use_php_sessions();
48 48
 
49
-		if ( $this->use_php_sessions ) {
50
-			if ( is_multisite() ) {
49
+		if ($this->use_php_sessions) {
50
+			if (is_multisite()) {
51 51
 				$this->prefix = '_' . get_current_blog_id();
52 52
 			}
53 53
 
54 54
 			// Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant)
55
-			add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
55
+			add_action('init', array($this, 'maybe_start_session'), -2);
56 56
 		} else {
57 57
 			// Use WP_Session (default)
58
-			if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
-				define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' );
58
+			if (!defined('WP_SESSION_COOKIE')) {
59
+				define('WP_SESSION_COOKIE', 'wpinv_wp_session');
60 60
 			}
61 61
 
62
-			if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
62
+			if (!class_exists('Recursive_ArrayAccess')) {
63 63
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php';
64 64
 			}
65 65
             
66
-			if ( !class_exists( 'WP_Session_Utils' ) ) {
66
+			if (!class_exists('WP_Session_Utils')) {
67 67
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php';
68 68
 			}
69 69
             
70
-			if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) {
70
+			if (defined('WP_CLI') && WP_CLI && !class_exists('WP_Session_Command')) {
71 71
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php';
72 72
 			}
73 73
 
74
-			if ( !class_exists( 'WP_Session' ) ) {
74
+			if (!class_exists('WP_Session')) {
75 75
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php';
76 76
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php';
77 77
 			}
78 78
 
79
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
80
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
79
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
80
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
81 81
 		}
82 82
 
83
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
84
-			add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
83
+		if (empty($this->session) && !$this->use_php_sessions) {
84
+			add_action('plugins_loaded', array($this, 'init'), -1);
85 85
 		} else {
86
-			add_action( 'init', array( $this, 'init' ), -1 );
86
+			add_action('init', array($this, 'init'), -1);
87 87
 		}
88 88
 	}
89 89
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	public function init() {
98
-		if ( $this->use_php_sessions ) {
99
-			$this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array();
98
+		if ($this->use_php_sessions) {
99
+			$this->session = isset($_SESSION['wpi' . $this->prefix]) && is_array($_SESSION['wpi' . $this->prefix]) ? $_SESSION['wpi' . $this->prefix] : array();
100 100
 		} else {
101 101
 			$this->session = WP_Session::get_instance();
102 102
 		}
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 * @return string Session ID
113 113
 	 */
114 114
 	public function get_id() {
115
-		if ( $this->use_php_sessions ) {
116
-			$session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL;
115
+		if ($this->use_php_sessions) {
116
+			$session_id = !empty($_SESSION) && function_exists('session_id') ? session_id() : NULL;
117 117
 		} else {
118
-			$session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL;
118
+			$session_id = !empty($this->session) && isset($this->session->session_id) ? $this->session->session_id : NULL;
119 119
 		}
120 120
 		return $session_id;
121 121
 	}
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 * @param string $key Session key
129 129
 	 * @return string Session variable
130 130
 	 */
131
-	public function get( $key ) {
132
-		$key = sanitize_key( $key );
133
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
131
+	public function get($key) {
132
+		$key = sanitize_key($key);
133
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 	 * @param integer $value Session variable
143 143
 	 * @return string Session variable
144 144
 	 */
145
-	public function set( $key, $value ) {
146
-		$key = sanitize_key( $key );
145
+	public function set($key, $value) {
146
+		$key = sanitize_key($key);
147 147
 
148
-		if ( is_array( $value ) ) {
149
-			$this->session[ $key ] = maybe_serialize( $value );
148
+		if (is_array($value)) {
149
+			$this->session[$key] = maybe_serialize($value);
150 150
 		} else {
151
-			$this->session[ $key ] = $value;
151
+			$this->session[$key] = $value;
152 152
 		}
153 153
 
154
-		if ( $this->use_php_sessions ) {
155
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
154
+		if ($this->use_php_sessions) {
155
+			$_SESSION['wpi' . $this->prefix] = $this->session;
156 156
 		}
157 157
 
158
-		return $this->session[ $key ];
158
+		return $this->session[$key];
159 159
 	}
160 160
 	
161 161
 	/**
@@ -167,29 +167,29 @@  discard block
 block discarded – undo
167 167
 	 * @param integer $value Session variable.
168 168
 	 * @return string Session variable.
169 169
 	 */
170
-	public function un_set( $key ) {
171
-		if ( empty( $key ) ) {
170
+	public function un_set($key) {
171
+		if (empty($key)) {
172 172
 			return false;
173 173
 		}
174 174
 		
175
-		if ( is_array( $key ) ) {
175
+		if (is_array($key)) {
176 176
 			foreach ($key as $index) {
177
-				$index = sanitize_key( $index );
177
+				$index = sanitize_key($index);
178 178
 			
179
-				if ( $index && isset( $this->session[ $index ] ) ) {
180
-					unset( $this->session[ $index ] );
179
+				if ($index && isset($this->session[$index])) {
180
+					unset($this->session[$index]);
181 181
 				}
182 182
 			}
183 183
 		} else {
184
-			$key = sanitize_key( $key );
184
+			$key = sanitize_key($key);
185 185
 			
186
-			if ( isset( $this->session[ $key ] ) ) {
187
-				unset( $this->session[ $key ] );
186
+			if (isset($this->session[$key])) {
187
+				unset($this->session[$key]);
188 188
 			}
189 189
 		}
190 190
 
191
-		if ( $this->use_php_sessions ) {
192
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
191
+		if ($this->use_php_sessions) {
192
+			$_SESSION['wpi' . $this->prefix] = $this->session;
193 193
 		}
194 194
 
195 195
 		return true;
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	 * @param integer $value Session variable.
205 205
 	 * @return string Session variable.
206 206
 	 */
207
-	public function is_set( $key ) {
208
-		$key = sanitize_key( $key );
207
+	public function is_set($key) {
208
+		$key = sanitize_key($key);
209 209
 		
210
-		if ( empty( $key ) ) {
210
+		if (empty($key)) {
211 211
 			return false;
212 212
 		}
213 213
 
214
-		if ( isset( $this->session[ $key ] ) ) {
214
+		if (isset($this->session[$key])) {
215 215
 			return true;
216 216
 		}
217 217
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param int $exp Default expiration (1 hour)
227 227
 	 * @return int
228 228
 	 */
229
-	public function set_expiration_variant_time( $exp ) {
230
-		return ( 30 * 60 * 23 );
229
+	public function set_expiration_variant_time($exp) {
230
+		return (30 * 60 * 23);
231 231
 	}
232 232
 
233 233
 	/**
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param int $exp Default expiration (1 hour)
239 239
 	 * @return int
240 240
 	 */
241
-	public function set_expiration_time( $exp ) {
242
-		return ( 30 * 60 * 24 );
241
+	public function set_expiration_time($exp) {
242
+		return (30 * 60 * 24);
243 243
 	}
244 244
 
245 245
 	/**
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 		$ret = false;
258 258
 
259 259
 		// If the database variable is already set, no need to run autodetection
260
-		$wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' );
260
+		$wpinv_use_php_sessions = (bool)get_option('wpinv_use_php_sessions');
261 261
 
262
-		if (!$wpinv_use_php_sessions ) {
262
+		if (!$wpinv_use_php_sessions) {
263 263
 			// Attempt to detect if the server supports PHP sessions
264
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
265
-				$this->set( 'wpinv_use_php_sessions', 1 );
264
+			if (function_exists('session_start') && !ini_get('safe_mode')) {
265
+				$this->set('wpinv_use_php_sessions', 1);
266 266
 				
267
-				if ( $this->get( 'wpinv_use_php_sessions' ) ) {
267
+				if ($this->get('wpinv_use_php_sessions')) {
268 268
 					$ret = true;
269 269
 
270 270
 					// Set the database option
271
-					update_option( 'wpinv_use_php_sessions', true );
271
+					update_option('wpinv_use_php_sessions', true);
272 272
 				}
273 273
 			}
274 274
 		} else {
@@ -276,20 +276,20 @@  discard block
 block discarded – undo
276 276
 		}
277 277
 
278 278
 		// Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant
279
-		if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) {
279
+		if (defined('WPINV_USE_PHP_SESSIONS') && WPINV_USE_PHP_SESSIONS) {
280 280
 			$ret = true;
281
-		} else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) {
281
+		} else if (defined('WPINV_USE_PHP_SESSIONS') && !WPINV_USE_PHP_SESSIONS) {
282 282
 			$ret = false;
283 283
 		}
284 284
 
285
-		return (bool) apply_filters( 'wpinv_use_php_sessions', $ret );
285
+		return (bool)apply_filters('wpinv_use_php_sessions', $ret);
286 286
 	}
287 287
 
288 288
 	/**
289 289
 	 * Starts a new session if one hasn't started yet.
290 290
 	 */
291 291
 	public function maybe_start_session() {
292
-		if ( !session_id() && !headers_sent() ) {
292
+		if (!session_id() && !headers_sent()) {
293 293
 			session_start();
294 294
 		}
295 295
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined( 'ABSPATH' ) ) {
4
+    exit;
5
+}
4 6
 
5 7
 /**
6 8
  * WPInv_Session Class.
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetAIM.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      * @param string $card_num The credit card number
102 102
      * @param string $exp_date CC expiration date
103 103
      *
104
-     * @return AuthorizeNetAIM_Response
104
+     * @return AuthorizeNetARB_Response
105 105
      */
106 106
     public function authorizeAndCapture($amount = false, $card_num = false, $exp_date = false)
107 107
     {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param string $trans_id Transaction id to charge
123 123
      * @param string $amount   Dollar amount to charge if lesser than auth
124 124
      *
125
-     * @return AuthorizeNetAIM_Response
125
+     * @return AuthorizeNetARB_Response
126 126
      */
127 127
     public function priorAuthCapture($trans_id = false, $amount = false)
128 128
     {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      * @param string $card_num The credit card number
142 142
      * @param string $exp_date CC expiration date
143 143
      *
144
-     * @return AuthorizeNetAIM_Response
144
+     * @return AuthorizeNetARB_Response
145 145
      */
146 146
     public function authorizeOnly($amount = false, $card_num = false, $exp_date = false)
147 147
     {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
      *
161 161
      * @param string $trans_id Transaction id to void
162 162
      *
163
-     * @return AuthorizeNetAIM_Response
163
+     * @return AuthorizeNetARB_Response
164 164
      */
165 165
     public function void($trans_id = false)
166 166
     {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * @param string $card_num  The last 4 of credit card number
180 180
      * @param string $exp_date  CC expiration date
181 181
      *
182
-     * @return AuthorizeNetAIM_Response
182
+     * @return AuthorizeNetARB_Response
183 183
      */
184 184
     public function captureOnly($auth_code = false, $amount = false, $card_num = false, $exp_date = false)
185 185
     {
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      * @param string $amount   The dollar amount to credit
201 201
      * @param string $card_num The last 4 of credit card number
202 202
      *
203
-     * @return AuthorizeNetAIM_Response
203
+     * @return AuthorizeNetARB_Response
204 204
      */
205 205
     public function credit($trans_id = false, $amount = false, $card_num = false)
206 206
     {
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
      * A list of all fields in the AIM API.
78 78
      * Used to warn user if they try to set a field not offered in the API.
79 79
      */
80
-    private $_all_aim_fields = array("address","allow_partial_auth","amount",
81
-        "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name",
82
-        "bank_acct_num","bank_acct_type","bank_check_number","bank_name",
83
-        "card_code","card_num","cardholder_authentication_value","city","company",
84
-        "country","cust_id","customer_ip","delim_char","delim_data","description",
85
-        "duplicate_window","duty","echeck_type","email","email_customer",
86
-        "encap_char","exp_date","fax","first_name","footer_email_receipt",
87
-        "freight","header_email_receipt","invoice_num","last_name","line_item",
88
-        "login","method","phone","po_num","recurring_billing","relay_response",
89
-        "ship_to_address","ship_to_city","ship_to_company","ship_to_country",
90
-        "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip",
91
-        "split_tender_id","state","tax","tax_exempt","test_request","tran_key",
92
-        "trans_id","type","version","zip"
80
+    private $_all_aim_fields = array("address", "allow_partial_auth", "amount",
81
+        "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name",
82
+        "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name",
83
+        "card_code", "card_num", "cardholder_authentication_value", "city", "company",
84
+        "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description",
85
+        "duplicate_window", "duty", "echeck_type", "email", "email_customer",
86
+        "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt",
87
+        "freight", "header_email_receipt", "invoice_num", "last_name", "line_item",
88
+        "login", "method", "phone", "po_num", "recurring_billing", "relay_response",
89
+        "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country",
90
+        "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip",
91
+        "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key",
92
+        "trans_id", "type", "version", "zip"
93 93
         );
94 94
     
95 95
     /**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             // Split Array
404 404
             $this->response = $response;
405 405
             if ($encap_char) {
406
-                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
406
+                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
407 407
             } else {
408 408
                 $this->_response_array = explode($delimiter, $response);
409 409
             }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             $this->duty                 = $this->_response_array[33];
458 458
             $this->freight              = $this->_response_array[34];
459 459
             $this->tax_exempt           = $this->_response_array[35];
460
-            $this->purchase_order_number= $this->_response_array[36];
460
+            $this->purchase_order_number = $this->_response_array[36];
461 461
             $this->md5_hash             = $this->_response_array[37];
462 462
             $this->card_code_response   = $this->_response_array[38];
463 463
             $this->cavv_response        = $this->_response_array[39];
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
             
485 485
             if ($this->error) {
486 486
                 $this->error_message = "AuthorizeNet Error:
487
-                Response Code: ".$this->response_code."
488
-                Response Subcode: ".$this->response_subcode."
489
-                Response Reason Code: ".$this->response_reason_code."
490
-                Response Reason Text: ".$this->response_reason_text."
487
+                Response Code: ".$this->response_code . "
488
+                Response Subcode: ".$this->response_subcode . "
489
+                Response Reason Code: ".$this->response_reason_code . "
490
+                Response Reason Text: ".$this->response_reason_text . "
491 491
                 ";
492 492
             }
493 493
         } else {
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCIM.php 3 patches
Doc Comments   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      * @param AuthorizeNetCustomer $customerProfile
52 52
      * @param string               $validationMode
53 53
      *
54
-     * @return AuthorizeNetCIM_Response
54
+     * @return AuthorizeNetARB_Response
55 55
      */
56 56
     public function createCustomerProfile($customerProfile, $validationMode = "none")
57 57
     {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param AuthorizeNetPaymentProfile $paymentProfile
70 70
      * @param string                     $validationMode
71 71
      *
72
-     * @return AuthorizeNetCIM_Response
72
+     * @return AuthorizeNetARB_Response
73 73
      */
74 74
     public function createCustomerPaymentProfile($customerProfileId, $paymentProfile, $validationMode = "none")
75 75
     {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param int                        $customerProfileId
88 88
      * @param AuthorizeNetAddress        $shippingAddress
89 89
      *
90
-     * @return AuthorizeNetCIM_Response
90
+     * @return AuthorizeNetARB_Response
91 91
      */
92 92
     public function createCustomerShippingAddress($customerProfileId, $shippingAddress)
93 93
     {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      * @param AuthorizeNetTransaction    $transaction
106 106
      * @param string                     $extraOptionsString
107 107
      *
108
-     * @return AuthorizeNetCIM_Response
108
+     * @return AuthorizeNetARB_Response
109 109
      */
110 110
     public function createCustomerProfileTransaction($transactionType, $transaction, $extraOptionsString = "")
111 111
     {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      *
123 123
      * @param int $customerProfileId
124 124
      *
125
-     * @return AuthorizeNetCIM_Response
125
+     * @return AuthorizeNetARB_Response
126 126
      */
127 127
     public function deleteCustomerProfile($customerProfileId)
128 128
     {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      * @param int $customerProfileId
138 138
      * @param int $customerPaymentProfileId
139 139
      *
140
-     * @return AuthorizeNetCIM_Response
140
+     * @return AuthorizeNetARB_Response
141 141
      */
142 142
     public function deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId)
143 143
     {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * @param int $customerProfileId
154 154
      * @param int $customerAddressId
155 155
      *
156
-     * @return AuthorizeNetCIM_Response
156
+     * @return AuthorizeNetARB_Response
157 157
      */
158 158
     public function deleteCustomerShippingAddress($customerProfileId, $customerAddressId)
159 159
     {
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     /**
167 167
      * Get all customer profile ids.
168 168
      *
169
-     * @return AuthorizeNetCIM_Response
169
+     * @return AuthorizeNetARB_Response
170 170
      */
171 171
     public function getCustomerProfileIds()
172 172
     {
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      *
180 180
      * @param int $customerProfileId
181 181
      *
182
-     * @return AuthorizeNetCIM_Response
182
+     * @return AuthorizeNetARB_Response
183 183
      */
184 184
     public function getCustomerProfile($customerProfileId)
185 185
     {
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      * @param int $customerProfileId
195 195
      * @param int $customerPaymentProfileId
196 196
      *
197
-     * @return AuthorizeNetCIM_Response
197
+     * @return AuthorizeNetARB_Response
198 198
      */
199 199
     public function getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId)
200 200
     {
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      * @param int $customerProfileId
211 211
      * @param int $customerAddressId
212 212
      *
213
-     * @return AuthorizeNetCIM_Response
213
+     * @return AuthorizeNetARB_Response
214 214
      */
215 215
     public function getCustomerShippingAddress($customerProfileId, $customerAddressId)
216 216
     {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @param int                        $customerProfileId
227 227
      * @param AuthorizeNetCustomer       $customerProfile
228 228
      *
229
-     * @return AuthorizeNetCIM_Response
229
+     * @return AuthorizeNetARB_Response
230 230
      */
231 231
     public function updateCustomerProfile($customerProfileId, $customerProfile)
232 232
     {
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
      * @param AuthorizeNetPaymentProfile $paymentProfile
246 246
      * @param string                     $validationMode
247 247
      *
248
-     * @return AuthorizeNetCIM_Response
248
+     * @return AuthorizeNetARB_Response
249 249
      */
250 250
     public function updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $paymentProfile, $validationMode = "none")
251 251
     {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      * @param int                        $customerShippingAddressId
266 266
      * @param AuthorizeNetAddress        $shippingAddress
267 267
      *
268
-     * @return AuthorizeNetCIM_Response
268
+     * @return AuthorizeNetARB_Response
269 269
      */
270 270
     public function updateCustomerShippingAddress($customerProfileId, $customerShippingAddressId, $shippingAddress)
271 271
     {
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
      * @param int                        $splitTenderId
285 285
      * @param string                     $splitTenderStatus
286 286
      *
287
-     * @return AuthorizeNetCIM_Response
287
+     * @return AuthorizeNetARB_Response
288 288
      */
289 289
     public function updateSplitTenderGroup($splitTenderId, $splitTenderStatus)
290 290
     {
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
      * @param int                        $cardCode
304 304
      * @param string                     $validationMode
305 305
      *
306
-     * @return AuthorizeNetCIM_Response
306
+     * @return AuthorizeNetARB_Response
307 307
      */
308 308
     public function validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $customerShippingAddressId, $cardCode, $validationMode = "testMode")
309 309
     {
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -316,9 +316,9 @@
 block discarded – undo
316 316
         return $this->_sendRequest();
317 317
     }
318 318
     
319
-     /**
320
-     * @return string
321
-     */
319
+        /**
320
+         * @return string
321
+         */
322 322
     protected function _getPostUrl()
323 323
     {
324 324
         return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
     {
310 310
         $this->_validationMode = $validationMode;
311 311
         $this->_constructXml("validateCustomerPaymentProfileRequest");
312
-        $this->_xml->addChild("customerProfileId",$customerProfileId);
313
-        $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId);
314
-        $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId);
315
-        $this->_xml->addChild("cardCode",$cardCode);
312
+        $this->_xml->addChild("customerProfileId", $customerProfileId);
313
+        $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);
314
+        $this->_xml->addChild("customerShippingAddressId", $customerShippingAddressId);
315
+        $this->_xml->addChild("cardCode", $cardCode);
316 316
         return $this->_sendRequest();
317 317
     }
318 318
     
@@ -341,13 +341,13 @@  discard block
 block discarded – undo
341 341
      */
342 342
     protected function _setPostString()
343 343
     {
344
-        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : "");
344
+        ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode', $this->_validationMode) : "");
345 345
         $this->_post_string = $this->_xml->asXML();
346 346
         
347 347
         // Add extraOptions CDATA
348 348
         if ($this->_extraOptions) {
349 349
             $this->_xml->addChild("extraOptions");
350
-            $this->_post_string = str_replace("<extraOptions></extraOptions>",'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
350
+            $this->_post_string = str_replace("<extraOptions></extraOptions>", '<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
351 351
             $this->_extraOptions = false;
352 352
         }
353 353
         // Blank out our validation mode, so that we don't include it in calls that
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
      */
363 363
     private function _constructXml($request_type)
364 364
     {
365
-        $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
365
+        $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>';
366 366
         $this->_xml = @new SimpleXMLElement($string);
367 367
         $merchant = $this->_xml->addChild('merchantAuthentication');
368
-        $merchant->addChild('name',$this->_api_login);
369
-        $merchant->addChild('transactionKey',$this->_transaction_key);
370
-        ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : "");
368
+        $merchant->addChild('name', $this->_api_login);
369
+        $merchant->addChild('transactionKey', $this->_transaction_key);
370
+        ($this->_refId ? $this->_xml->addChild('refId', $this->_refId) : "");
371 371
     }
372 372
     
373 373
     /**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                         $this->_addObject($items, $item);
388 388
                     }
389 389
                 } else {
390
-                    $destination->addChild($key,$value);
390
+                    $destination->addChild($key, $value);
391 391
                 }
392 392
             } elseif (is_object($value) && self::_notEmpty($value)) {
393 393
                 $dest = $destination->addChild($key);
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetCP.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
      *
80 80
      * @param string $response
81 81
      * 
82
-     * @return AuthorizeNetAIM_Response
82
+     * @return AuthorizeNetCP_Response
83 83
      */
84 84
     protected function _handleResponse($response)
85 85
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 
117 117
                 $this->xml = @simplexml_load_string($response);
118 118
                 // Set all fields
119
-                $this->version              = array_pop(array_slice(explode('"', $response), 1,1));
119
+                $this->version              = array_pop(array_slice(explode('"', $response), 1, 1));
120 120
                 $this->response_code        = (string)$this->xml->ResponseCode;
121 121
                 
122 122
                 if ($this->response_code == 1) {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                 // Split Array
145 145
                 $this->response = $response;
146 146
                 if ($encap_char) {
147
-                    $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
147
+                    $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
148 148
                 } else {
149 149
                     $this->_response_array = explode($delimiter, $response);
150 150
                 }
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
             
191 191
             if ($this->error) {
192 192
                 $this->error_message = "AuthorizeNet Error:
193
-                Response Code: ".$this->response_code."
194
-                Response Reason Code: ".$this->response_reason_code."
195
-                Response Reason Text: ".$this->response_reason_text."
193
+                Response Code: ".$this->response_code . "
194
+                Response Reason Code: ".$this->response_reason_code . "
195
+                Response Reason Text: ".$this->response_reason_text . "
196 196
                 ";
197 197
             }
198 198
             
Please login to merge, or discard this patch.
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetRequest.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -28,6 +28,7 @@
 block discarded – undo
28 28
     /**
29 29
      * Get the post url. We need this because until 5.3 you
30 30
      * you could not access child constants in a parent class.
31
+     * @return string|null
31 32
      */
32 33
     abstract protected function _getPostUrl();
33 34
     
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
             curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
97 97
         }
98 98
         
99
-        if (preg_match('/xml/',$post_url)) {
99
+        if (preg_match('/xml/', $post_url)) {
100 100
             curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
101 101
         }
102 102
         
Please login to merge, or discard this patch.
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -110,6 +110,7 @@
 block discarded – undo
110 110
      * Grabs the contents of a unique element.
111 111
      *
112 112
      * @param  string
113
+     * @param string $elementName
113 114
      * @return string
114 115
      */
115 116
     protected function _getElementContents($elementName) 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             $this->xml = @simplexml_load_string($response);
30 30
             
31 31
             // Remove namespaces for use with XPath.
32
-            $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/','',$response));
32
+            $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/', '', $response));
33 33
         }
34 34
     }
35 35
     
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $start = "<$elementName>";
118 118
         $end = "</$elementName>";
119
-        if (strpos($this->response,$start) === false || strpos($this->response,$end) === false) {
119
+        if (strpos($this->response, $start) === false || strpos($this->response, $end) === false) {
120 120
             return false;
121 121
         } else {
122
-            $start_position = strpos($this->response, $start)+strlen($start);
122
+            $start_position = strpos($this->response, $start) + strlen($start);
123 123
             $end_position = strpos($this->response, $end);
124
-            return substr($this->response, $start_position, $end_position-$start_position);
124
+            return substr($this->response, $start_position, $end_position - $start_position);
125 125
         }
126 126
     }
127 127
 
Please login to merge, or discard this patch.
includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -69,6 +69,7 @@  discard block
 block discarded – undo
69 69
      * remove XML response namespaces
70 70
      * without this php will spit out warinings
71 71
      * @see http://community.developer.authorize.net/t5/Integration-and-Testing/ARB-with-SimpleXML-PHP-Issue/m-p/7128#M5139
72
+     * @return string
72 73
      */
73 74
     private function removeResponseXMLNS($input)
74 75
     {
@@ -150,6 +151,9 @@  discard block
 block discarded – undo
150 151
 		$this->process();
151 152
 	}
152 153
 
154
+	/**
155
+	 * @param SimpleXMLElement $xml
156
+	 */
153 157
 	private function setParameters($xml, $array)
154 158
 	{
155 159
 	    if (is_array($array))
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     const EXCEPTION_CURL = 10;
41 41
 
42 42
     private $ch;
43
-	private $login;
43
+    private $login;
44 44
     private $response;
45 45
     private $response_xml;
46 46
     private $results;
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
     private $url;
49 49
     private $xml;
50 50
 
51
-	public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER)
52
-	{
53
-		$login    = trim($login);
51
+    public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER)
52
+    {
53
+        $login    = trim($login);
54 54
         $transkey = trim($transkey);
55 55
         if (empty($login) || empty($transkey))
56 56
         {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
         $subdomain = ($test) ? 'apitest' : 'api';
65 65
         $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api';
66
-	}
66
+    }
67 67
 
68 68
     /**
69 69
      * remove XML response namespaces
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
         return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input);
79 79
     }
80 80
 
81
-	public function __toString()
82
-	{
83
-	    $output  = '';
81
+    public function __toString()
82
+    {
83
+        $output  = '';
84 84
         $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n";
85 85
         $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n";
86 86
         $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n";
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
         $output .= '</table>';
118 118
 
119 119
         return $output;
120
-	}
120
+    }
121 121
 
122
-	public function __destruct()
122
+    public function __destruct()
123 123
     {
124 124
         if (isset($this->ch))
125 125
         {
@@ -128,31 +128,31 @@  discard block
 block discarded – undo
128 128
     }
129 129
 
130 130
     public function __get($var)
131
-	{
132
-	    return $this->response_xml->$var;
133
-	}
134
-
135
-	public function __set($key, $value)
136
-	{
137
-	    trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING);
138
-	    return false;
139
-	}
140
-
141
-	public function __call($api_call, $args)
142
-	{
143
-	    $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>');
131
+    {
132
+        return $this->response_xml->$var;
133
+    }
134
+
135
+    public function __set($key, $value)
136
+    {
137
+        trigger_error('You cannot set parameters directly in ' . __CLASS__ . '.', E_USER_WARNING);
138
+        return false;
139
+    }
140
+
141
+    public function __call($api_call, $args)
142
+    {
143
+        $this->xml = new SimpleXMLElement('<' . $api_call . '></' . $api_call . '>');
144 144
         $this->xml->addAttribute('xmlns', 'AnetApi/xml/v1/schema/AnetApiSchema.xsd');
145
-	    $merch_auth = $this->xml->addChild('merchantAuthentication');
145
+        $merch_auth = $this->xml->addChild('merchantAuthentication');
146 146
         $merch_auth->addChild('name', $this->login);
147
-	    $merch_auth->addChild('transactionKey', $this->transkey);
147
+        $merch_auth->addChild('transactionKey', $this->transkey);
148 148
 
149
-		$this->setParameters($this->xml, $args[0]);
150
-		$this->process();
151
-	}
149
+        $this->setParameters($this->xml, $args[0]);
150
+        $this->process();
151
+    }
152 152
 
153
-	private function setParameters($xml, $array)
154
-	{
155
-	    if (is_array($array))
153
+    private function setParameters($xml, $array)
154
+    {
155
+        if (is_array($array))
156 156
         {
157 157
             $first = true;
158 158
             foreach ($array as $key => $value)
@@ -184,34 +184,34 @@  discard block
 block discarded – undo
184 184
                 }
185 185
             }
186 186
         }
187
-	}
187
+    }
188 188
 
189
-	private function process()
190
-	{
191
-		$this->xml = $this->xml->asXML();
189
+    private function process()
190
+    {
191
+        $this->xml = $this->xml->asXML();
192 192
 
193
-		$this->ch = curl_init();
193
+        $this->ch = curl_init();
194 194
         curl_setopt($this->ch, CURLOPT_URL, $this->url);
195
-    	curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
196
-    	curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
197
-    	curl_setopt($this->ch, CURLOPT_HEADER, 0);
198
-    	curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml);
199
-    	curl_setopt($this->ch, CURLOPT_POST, 1);
200
-    	curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
201
-    	curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem');
195
+        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
196
+        curl_setopt($this->ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
197
+        curl_setopt($this->ch, CURLOPT_HEADER, 0);
198
+        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $this->xml);
199
+        curl_setopt($this->ch, CURLOPT_POST, 1);
200
+        curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
201
+        curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem');
202 202
 
203 203
         if(($this->response = curl_exec($this->ch)) !== false)
204 204
         {
205 205
             $this->response_xml = @new SimpleXMLElement($this->response);
206 206
 
207
-		    curl_close($this->ch);
207
+            curl_close($this->ch);
208 208
             unset($this->ch);
209 209
             return;
210
-		}
210
+        }
211 211
         throw new AuthnetXMLException('Connection error: ' . curl_error($this->ch) . ' (' . curl_errno($this->ch) . ')', self::EXCEPTION_CURL);
212
-	}
212
+    }
213 213
 
214
-	public function isSuccessful()
214
+    public function isSuccessful()
215 215
     {
216 216
         return $this->response_xml->messages->resultCode == 'Ok';
217 217
     }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 	public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER)
52 52
 	{
53
-		$login    = trim($login);
53
+		$login = trim($login);
54 54
         $transkey = trim($transkey);
55 55
         if (empty($login) || empty($transkey))
56 56
         {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $this->login    = trim($login);
61 61
         $this->transkey = trim($transkey);
62
-        $test           = (bool) $test;
62
+        $test           = (bool)$test;
63 63
 
64 64
         $subdomain = ($test) ? 'apitest' : 'api';
65 65
         $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api';
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
     private function removeResponseXMLNS($input)
74 74
     {
75 75
         // why remove them one at a time? all three aren't consistantly used in the response
76
-        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"','',$input);
77
-        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','',$input);
78
-        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input);
76
+        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $input);
77
+        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', '', $input);
78
+        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"', '', $input);
79 79
     }
80 80
 
81 81
 	public function __toString()
82 82
 	{
83
-	    $output  = '';
83
+	    $output = '';
84 84
         $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n";
85 85
         $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n";
86 86
         $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n";
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
             {
160 160
                 if (is_array($value))
161 161
                 {
162
-                    if(is_numeric($key))
162
+                    if (is_numeric($key))
163 163
                     {
164
-                        if($first === true)
164
+                        if ($first === true)
165 165
                         {
166 166
                             $xmlx  = $xml;
167 167
                             $first = false;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     	curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
201 201
     	curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem');
202 202
 
203
-        if(($this->response = curl_exec($this->ch)) !== false)
203
+        if (($this->response = curl_exec($this->ch)) !== false)
204 204
         {
205 205
             $this->response_xml = @new SimpleXMLElement($this->response);
206 206
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -165,20 +165,17 @@
 block discarded – undo
165 165
                         {
166 166
                             $xmlx  = $xml;
167 167
                             $first = false;
168
-                        }
169
-                        else
168
+                        } else
170 169
                         {
171 170
                             $parent = $xml->xpath('parent::*');
172 171
                             $xmlx = $parent[0]->addChild($xml->getName());
173 172
                         }
174
-                    }
175
-                    else
173
+                    } else
176 174
                     {
177 175
                         $xmlx = $xml->addChild($key);
178 176
                     }
179 177
                     $this->setParameters($xmlx, $value);
180
-                }
181
-                else
178
+                } else
182 179
                 {
183 180
                     $xml->$key = $value;
184 181
                 }
Please login to merge, or discard this patch.
includes/libraries/GeoIp2/WebService/Client.php 3 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -189,6 +189,11 @@
 block discarded – undo
189 189
         return $this->responseFor('insights', 'Insights', $ipAddress);
190 190
     }
191 191
 
192
+    /**
193
+     * @param string $endpoint
194
+     * @param string $class
195
+     * @param string $ipAddress
196
+     */
192 197
     private function responseFor($endpoint, $class, $ipAddress)
193 198
     {
194 199
         $path = implode('/', array(self::$basePath, $endpoint, $ipAddress));
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,6 @@
 block discarded – undo
9 9
 use GeoIp2\Exception\InvalidRequestException;
10 10
 use GeoIp2\Exception\OutOfQueriesException;
11 11
 use GeoIp2\ProviderInterface;
12
-use MaxMind\Exception\InvalidInputException;
13 12
 use MaxMind\WebService\Client as WsClient;
14 13
 
15 14
 /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
         // This is for backwards compatibility. Do not remove except for a
77 77
         // major version bump.
78 78
         if (is_string($options)) {
79
-            $options = array( 'host' => $options );
79
+            $options = array('host' => $options);
80 80
         }
81 81
 
82 82
         if (!isset($options['host'])) {
Please login to merge, or discard this patch.
includes/libraries/MaxMind/Db/Reader.php 1 patch
Doc Comments   +13 added lines patch added patch discarded remove patch
@@ -115,6 +115,9 @@  discard block
 block discarded – undo
115 115
         return $this->resolveDataPointer($pointer);
116 116
     }
117 117
 
118
+    /**
119
+     * @param string $ipAddress
120
+     */
118 121
     private function findAddressInTree($ipAddress)
119 122
     {
120 123
         // XXX - could simplify. Done as a byte array to ease porting
@@ -146,6 +149,9 @@  discard block
 block discarded – undo
146 149
     }
147 150
 
148 151
 
152
+    /**
153
+     * @param integer $length
154
+     */
149 155
     private function startNode($length)
150 156
     {
151 157
         // Check if we are looking up an IPv4 address in an IPv6 tree. If this
@@ -178,6 +184,9 @@  discard block
 block discarded – undo
178 184
         return $node;
179 185
     }
180 186
 
187
+    /**
188
+     * @param integer $index
189
+     */
181 190
     private function readNode($nodeNumber, $index)
182 191
     {
183 192
         $baseOffset = $nodeNumber * $this->metadata->nodeByteSize;
@@ -230,6 +239,10 @@  discard block
 block discarded – undo
230 239
      * are much faster algorithms (e.g., Boyer-Moore) for this if speed is ever
231 240
      * an issue, but I suspect it won't be.
232 241
      */
242
+
243
+    /**
244
+     * @param string $filename
245
+     */
233 246
     private function findMetadataStart($filename)
234 247
     {
235 248
         $handle = $this->fileHandle;
Please login to merge, or discard this patch.