Completed
Branch BUG/invalid-field-count (f53e3a)
by
unknown
09:18 queued 52s
created
core/services/request/middleware/PreProductionVersionWarning.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
     public function preProductionVersionAdminNotice()
79 79
     {
80 80
         new PersistentAdminNotice(
81
-            'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
81
+            'preProductionVersionAdminNotice_'.EVENT_ESPRESSO_VERSION,
82 82
             $this->warningNotice()
83 83
         );
84 84
     }
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -18,91 +18,91 @@
 block discarded – undo
18 18
 class PreProductionVersionWarning extends Middleware
19 19
 {
20 20
 
21
-    /**
22
-     * converts a Request to a Response
23
-     *
24
-     * @param RequestInterface  $request
25
-     * @param ResponseInterface $response
26
-     * @return ResponseInterface
27
-     */
28
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
29
-    {
30
-        $this->request = $request;
31
-        $this->response = $response;
32
-        $this->displayPreProductionVersionWarning();
33
-        $this->response = $this->processRequestStack($this->request, $this->response);
34
-        return $this->response;
35
-    }
21
+	/**
22
+	 * converts a Request to a Response
23
+	 *
24
+	 * @param RequestInterface  $request
25
+	 * @param ResponseInterface $response
26
+	 * @return ResponseInterface
27
+	 */
28
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
29
+	{
30
+		$this->request = $request;
31
+		$this->response = $response;
32
+		$this->displayPreProductionVersionWarning();
33
+		$this->response = $this->processRequestStack($this->request, $this->response);
34
+		return $this->response;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
40
-     *
41
-     * @return void
42
-     */
43
-    public function displayPreProductionVersionWarning()
44
-    {
45
-        // skip AJAX requests
46
-        if ($this->request->isAjax()) {
47
-            return;
48
-        }
49
-        // skip stable releases
50
-        if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') {
51
-            return;
52
-        }
53
-        // site admin has authorized use of non-stable release candidate for production
54
-        if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) {
55
-            return;
56
-        }
57
-        // post release candidate warning
58
-        if ($this->request->isAdmin()) {
59
-            add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999);
60
-        } else {
61
-            add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10);
62
-        }
63
-    }
38
+	/**
39
+	 * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function displayPreProductionVersionWarning()
44
+	{
45
+		// skip AJAX requests
46
+		if ($this->request->isAjax()) {
47
+			return;
48
+		}
49
+		// skip stable releases
50
+		if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') {
51
+			return;
52
+		}
53
+		// site admin has authorized use of non-stable release candidate for production
54
+		if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) {
55
+			return;
56
+		}
57
+		// post release candidate warning
58
+		if ($this->request->isAdmin()) {
59
+			add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999);
60
+		} else {
61
+			add_action('shutdown', array($this, 'preProductionVersionWarningNotice'), 10);
62
+		}
63
+	}
64 64
 
65 65
 
66
-    /**
67
-     * displays admin notice that current version of EE is not a stable release
68
-     *
69
-     * @return void
70
-     * @throws InvalidDataTypeException
71
-     */
72
-    public function preProductionVersionAdminNotice()
73
-    {
74
-        new PersistentAdminNotice(
75
-            'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
76
-            $this->warningNotice()
77
-        );
78
-    }
66
+	/**
67
+	 * displays admin notice that current version of EE is not a stable release
68
+	 *
69
+	 * @return void
70
+	 * @throws InvalidDataTypeException
71
+	 */
72
+	public function preProductionVersionAdminNotice()
73
+	{
74
+		new PersistentAdminNotice(
75
+			'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION,
76
+			$this->warningNotice()
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * displays message on frontend of site notifying admin that current version of EE is not a stable release
83
-     *
84
-     * @return void
85
-     */
86
-    public function preProductionVersionWarningNotice()
87
-    {
88
-        echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>';
89
-        echo $this->warningNotice();
90
-        echo '</p></div>';
91
-    }
81
+	/**
82
+	 * displays message on frontend of site notifying admin that current version of EE is not a stable release
83
+	 *
84
+	 * @return void
85
+	 */
86
+	public function preProductionVersionWarningNotice()
87
+	{
88
+		echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>';
89
+		echo $this->warningNotice();
90
+		echo '</p></div>';
91
+	}
92 92
 
93 93
 
94
-    /**
95
-     * @return string
96
-     */
97
-    private function warningNotice()
98
-    {
99
-        return sprintf(
100
-            esc_html__(
101
-                'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.',
102
-                'event_espresso'
103
-            ),
104
-            '<strong>',
105
-            '</strong>'
106
-        );
107
-    }
94
+	/**
95
+	 * @return string
96
+	 */
97
+	private function warningNotice()
98
+	{
99
+		return sprintf(
100
+			esc_html__(
101
+				'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.',
102
+				'event_espresso'
103
+			),
104
+			'<strong>',
105
+			'</strong>'
106
+		);
107
+	}
108 108
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@
 block discarded – undo
83 83
     {
84 84
         espresso_load_required(
85 85
             'EE_Request',
86
-            EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
86
+            EE_CORE.'request_stack'.DS.'EE_Request.core.php'
87 87
         );
88 88
         $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
89 89
         $this->legacy_request->setRequest($this->request);
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -25,80 +25,80 @@
 block discarded – undo
25 25
 class BootstrapRequestResponseObjects
26 26
 {
27 27
 
28
-    /**
29
-     * @type LegacyRequestInterface $legacy_request
30
-     */
31
-    protected $legacy_request;
28
+	/**
29
+	 * @type LegacyRequestInterface $legacy_request
30
+	 */
31
+	protected $legacy_request;
32 32
 
33
-    /**
34
-     * @type LoaderInterface $loader
35
-     */
36
-    protected $loader;
33
+	/**
34
+	 * @type LoaderInterface $loader
35
+	 */
36
+	protected $loader;
37 37
 
38
-    /**
39
-     * @var RequestInterface $request
40
-     */
41
-    protected $request;
38
+	/**
39
+	 * @var RequestInterface $request
40
+	 */
41
+	protected $request;
42 42
 
43
-    /**
44
-     * @var ResponseInterface $response
45
-     */
46
-    protected $response;
43
+	/**
44
+	 * @var ResponseInterface $response
45
+	 */
46
+	protected $response;
47 47
 
48 48
 
49
-    /**
50
-     * BootstrapRequestResponseObjects constructor.
51
-     *
52
-     * @param LoaderInterface $loader
53
-     */
54
-    public function __construct(LoaderInterface $loader)
55
-    {
56
-        $this->loader = $loader;
57
-    }
49
+	/**
50
+	 * BootstrapRequestResponseObjects constructor.
51
+	 *
52
+	 * @param LoaderInterface $loader
53
+	 */
54
+	public function __construct(LoaderInterface $loader)
55
+	{
56
+		$this->loader = $loader;
57
+	}
58 58
 
59 59
 
60
-    /**
61
-     * @return void
62
-     */
63
-    public function buildRequestResponse()
64
-    {
65
-        // load our Request and Response objects
66
-        $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER);
67
-        $this->response = new Response();
68
-    }
60
+	/**
61
+	 * @return void
62
+	 */
63
+	public function buildRequestResponse()
64
+	{
65
+		// load our Request and Response objects
66
+		$this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER);
67
+		$this->response = new Response();
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @return void
73
-     * @throws InvalidArgumentException
74
-     */
75
-    public function shareRequestResponse()
76
-    {
77
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
-        EE_Dependency_Map::instance()->setRequest($this->request);
80
-        EE_Dependency_Map::instance()->setResponse($this->response);
81
-    }
71
+	/**
72
+	 * @return void
73
+	 * @throws InvalidArgumentException
74
+	 */
75
+	public function shareRequestResponse()
76
+	{
77
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
78
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
79
+		EE_Dependency_Map::instance()->setRequest($this->request);
80
+		EE_Dependency_Map::instance()->setResponse($this->response);
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * @return void
86
-     * @throws InvalidArgumentException
87
-     * @throws EE_Error
88
-     */
89
-    public function setupLegacyRequest()
90
-    {
91
-        espresso_load_required(
92
-            'EE_Request',
93
-            EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
94
-        );
95
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
-        $this->legacy_request->setRequest($this->request);
97
-        $this->legacy_request->admin = $this->request->isAdmin();
98
-        $this->legacy_request->ajax = $this->request->isAjax();
99
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
-        $this->loader->share('EE_Request', $this->legacy_request);
102
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
-    }
84
+	/**
85
+	 * @return void
86
+	 * @throws InvalidArgumentException
87
+	 * @throws EE_Error
88
+	 */
89
+	public function setupLegacyRequest()
90
+	{
91
+		espresso_load_required(
92
+			'EE_Request',
93
+			EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
94
+		);
95
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
96
+		$this->legacy_request->setRequest($this->request);
97
+		$this->legacy_request->admin = $this->request->isAdmin();
98
+		$this->legacy_request->ajax = $this->request->isAjax();
99
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
100
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
101
+		$this->loader->share('EE_Request', $this->legacy_request);
102
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
103
+	}
104 104
 }
Please login to merge, or discard this patch.
core/request_stack/EE_Request.core.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      *
182 182
      * @deprecated 4.9.53
183 183
      * @param      $key
184
-     * @param null $default
184
+     * @param null|string $default
185 185
      * @return mixed
186 186
      * @throws InvalidArgumentException
187 187
      * @throws InvalidDataTypeException
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
     /**
258 258
      * @deprecated 4.9.53
259
-     * @return mixed
259
+     * @return boolean
260 260
      * @throws InvalidArgumentException
261 261
      * @throws InvalidDataTypeException
262 262
      * @throws InvalidInterfaceException
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
     /**
271 271
      * @deprecated 4.9.53
272
-     * @return mixed
272
+     * @return boolean
273 273
      * @throws InvalidArgumentException
274 274
      * @throws InvalidDataTypeException
275 275
      * @throws InvalidInterfaceException
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
     /**
284 284
      * @deprecated 4.9.53
285
-     * @return mixed|string
285
+     * @return string
286 286
      * @throws InvalidArgumentException
287 287
      * @throws InvalidDataTypeException
288 288
      * @throws InvalidInterfaceException
Please login to merge, or discard this patch.
Indentation   +355 added lines, -355 removed lines patch added patch discarded remove patch
@@ -18,359 +18,359 @@
 block discarded – undo
18 18
 class EE_Request implements LegacyRequestInterface, InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var RequestInterface $request
23
-     */
24
-    private $request;
25
-
26
-    /**
27
-     * whether current request is for the admin but NOT via AJAX
28
-     *
29
-     * @var boolean $admin
30
-     */
31
-    public $admin = false;
32
-
33
-    /**
34
-     * whether current request is via AJAX
35
-     *
36
-     * @var boolean $ajax
37
-     */
38
-    public $ajax = false;
39
-
40
-    /**
41
-     * whether current request is via AJAX from the frontend of the site
42
-     *
43
-     * @var boolean $front_ajax
44
-     */
45
-    public $front_ajax = false;
46
-
47
-
48
-    /**
49
-     * @deprecated 4.9.53
50
-     * @param array $get
51
-     * @param array $post
52
-     * @param array $cookie
53
-     * @param array $server
54
-     */
55
-    public function __construct(
56
-        array $get = array(),
57
-        array $post = array(),
58
-        array $cookie = array(),
59
-        array $server = array()
60
-    ) {
61
-    }
62
-
63
-
64
-    /**
65
-     * @return RequestInterface
66
-     * @throws InvalidArgumentException
67
-     * @throws InvalidInterfaceException
68
-     * @throws InvalidDataTypeException
69
-     */
70
-    private function request()
71
-    {
72
-        if ($this->request instanceof RequestInterface) {
73
-            return $this->request;
74
-        }
75
-        $loader = LoaderFactory::getLoader();
76
-        $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface');
77
-        return $this->request;
78
-    }
79
-
80
-
81
-    /**
82
-     * @param RequestInterface $request
83
-     */
84
-    public function setRequest(RequestInterface $request)
85
-    {
86
-        $this->request = $request;
87
-    }
88
-
89
-
90
-    /**
91
-     * @deprecated 4.9.53
92
-     * @return array
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidDataTypeException
95
-     * @throws InvalidInterfaceException
96
-     */
97
-    public function get_params()
98
-    {
99
-        return $this->request()->getParams();
100
-    }
101
-
102
-
103
-    /**
104
-     * @deprecated 4.9.53
105
-     * @return array
106
-     * @throws InvalidArgumentException
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     */
110
-    public function post_params()
111
-    {
112
-        return $this->request()->postParams();
113
-    }
114
-
115
-
116
-    /**
117
-     * @deprecated 4.9.53
118
-     * @return array
119
-     * @throws InvalidArgumentException
120
-     * @throws InvalidDataTypeException
121
-     * @throws InvalidInterfaceException
122
-     */
123
-    public function cookie_params()
124
-    {
125
-        return $this->request()->cookieParams();
126
-    }
127
-
128
-
129
-    /**
130
-     * @deprecated 4.9.53
131
-     * @return array
132
-     * @throws InvalidArgumentException
133
-     * @throws InvalidDataTypeException
134
-     * @throws InvalidInterfaceException
135
-     */
136
-    public function server_params()
137
-    {
138
-        return $this->request()->serverParams();
139
-    }
140
-
141
-
142
-    /**
143
-     * returns contents of $_REQUEST
144
-     *
145
-     * @deprecated 4.9.53
146
-     * @return array
147
-     * @throws InvalidArgumentException
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidInterfaceException
150
-     */
151
-    public function params()
152
-    {
153
-        return $this->request()->requestParams();
154
-    }
155
-
156
-
157
-    /**
158
-     * @deprecated 4.9.53
159
-     * @param      $key
160
-     * @param      $value
161
-     * @param bool $override_ee
162
-     * @return void
163
-     * @throws InvalidArgumentException
164
-     * @throws InvalidDataTypeException
165
-     * @throws InvalidInterfaceException
166
-     */
167
-    public function set($key, $value, $override_ee = false)
168
-    {
169
-        $this->request()->setRequestParam($key, $value, $override_ee);
170
-    }
171
-
172
-
173
-    /**
174
-     * returns   the value for a request param if the given key exists
175
-     *
176
-     * @deprecated 4.9.53
177
-     * @param      $key
178
-     * @param null $default
179
-     * @return mixed
180
-     * @throws InvalidArgumentException
181
-     * @throws InvalidDataTypeException
182
-     * @throws InvalidInterfaceException
183
-     */
184
-    public function get($key, $default = null)
185
-    {
186
-        return $this->request()->getRequestParam($key, $default);
187
-    }
188
-
189
-
190
-    /**
191
-     * check if param exists
192
-     *
193
-     * @deprecated 4.9.53
194
-     * @param $key
195
-     * @return bool
196
-     * @throws InvalidArgumentException
197
-     * @throws InvalidDataTypeException
198
-     * @throws InvalidInterfaceException
199
-     */
200
-    public function is_set($key)
201
-    {
202
-        return $this->request()->requestParamIsSet($key);
203
-    }
204
-
205
-
206
-    /**
207
-     * remove param
208
-     *
209
-     * @deprecated 4.9.53
210
-     * @param      $key
211
-     * @param bool $unset_from_global_too
212
-     * @throws InvalidArgumentException
213
-     * @throws InvalidDataTypeException
214
-     * @throws InvalidInterfaceException
215
-     */
216
-    public function un_set($key, $unset_from_global_too = false)
217
-    {
218
-        $this->request()->unSetRequestParam($key, $unset_from_global_too);
219
-    }
220
-
221
-
222
-    /**
223
-     * @deprecated 4.9.53
224
-     * @return string
225
-     * @throws InvalidArgumentException
226
-     * @throws InvalidDataTypeException
227
-     * @throws InvalidInterfaceException
228
-     */
229
-    public function ip_address()
230
-    {
231
-        return $this->request()->ipAddress();
232
-    }
233
-
234
-
235
-    /**
236
-     * @deprecated 4.9.53
237
-     * @return bool
238
-     * @throws InvalidArgumentException
239
-     * @throws InvalidDataTypeException
240
-     * @throws InvalidInterfaceException
241
-     */
242
-    public function isAdmin()
243
-    {
244
-        return $this->request()->isAdmin();
245
-    }
246
-
247
-
248
-    /**
249
-     * @deprecated 4.9.53
250
-     * @return mixed
251
-     * @throws InvalidArgumentException
252
-     * @throws InvalidDataTypeException
253
-     * @throws InvalidInterfaceException
254
-     */
255
-    public function isAjax()
256
-    {
257
-        return $this->request()->isAjax();
258
-    }
259
-
260
-
261
-    /**
262
-     * @deprecated 4.9.53
263
-     * @return mixed
264
-     * @throws InvalidArgumentException
265
-     * @throws InvalidDataTypeException
266
-     * @throws InvalidInterfaceException
267
-     */
268
-    public function isFrontAjax()
269
-    {
270
-        return $this->request()->isFrontAjax();
271
-    }
272
-
273
-
274
-    /**
275
-     * @deprecated 4.9.53
276
-     * @return mixed|string
277
-     * @throws InvalidArgumentException
278
-     * @throws InvalidDataTypeException
279
-     * @throws InvalidInterfaceException
280
-     */
281
-    public function requestUri()
282
-    {
283
-        return $this->request()->requestUri();
284
-    }
285
-
286
-
287
-    /**
288
-     * @deprecated 4.9.53
289
-     * @return string
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidDataTypeException
292
-     * @throws InvalidInterfaceException
293
-     */
294
-    public function userAgent()
295
-    {
296
-        return $this->request()->userAgent();
297
-    }
298
-
299
-
300
-    /**
301
-     * @deprecated 4.9.53
302
-     * @param string $user_agent
303
-     * @throws InvalidArgumentException
304
-     * @throws InvalidDataTypeException
305
-     * @throws InvalidInterfaceException
306
-     */
307
-    public function setUserAgent($user_agent = '')
308
-    {
309
-        $this->request()->setUserAgent($user_agent);
310
-    }
311
-
312
-
313
-    /**
314
-     * @deprecated 4.9.53
315
-     * @return bool
316
-     * @throws InvalidArgumentException
317
-     * @throws InvalidDataTypeException
318
-     * @throws InvalidInterfaceException
319
-     */
320
-    public function isBot()
321
-    {
322
-        return $this->request()->isBot();
323
-    }
324
-
325
-
326
-    /**
327
-     * @deprecated 4.9.53
328
-     * @param bool $is_bot
329
-     * @throws InvalidArgumentException
330
-     * @throws InvalidDataTypeException
331
-     * @throws InvalidInterfaceException
332
-     */
333
-    public function setIsBot($is_bot)
334
-    {
335
-        $this->request()->setIsBot($is_bot);
336
-    }
337
-
338
-
339
-    /**
340
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
341
-     * and return the value for the first match found
342
-     * wildcards can be either of the following:
343
-     *      ? to represent a single character of any type
344
-     *      * to represent one or more characters of any type
345
-     *
346
-     * @param string     $pattern
347
-     * @param null|mixed $default
348
-     * @return false|int
349
-     * @throws InvalidArgumentException
350
-     * @throws InvalidInterfaceException
351
-     * @throws InvalidDataTypeException
352
-     */
353
-    public function getMatch($pattern, $default = null)
354
-    {
355
-        return $this->request()->getMatch($pattern, $default);
356
-    }
357
-
358
-
359
-    /**
360
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
361
-     * wildcards can be either of the following:
362
-     *      ? to represent a single character of any type
363
-     *      * to represent one or more characters of any type
364
-     * returns true if a match is found or false if not
365
-     *
366
-     * @param string $pattern
367
-     * @return false|int
368
-     * @throws InvalidArgumentException
369
-     * @throws InvalidInterfaceException
370
-     * @throws InvalidDataTypeException
371
-     */
372
-    public function matches($pattern)
373
-    {
374
-        return $this->request()->matches($pattern);
375
-    }
21
+	/**
22
+	 * @var RequestInterface $request
23
+	 */
24
+	private $request;
25
+
26
+	/**
27
+	 * whether current request is for the admin but NOT via AJAX
28
+	 *
29
+	 * @var boolean $admin
30
+	 */
31
+	public $admin = false;
32
+
33
+	/**
34
+	 * whether current request is via AJAX
35
+	 *
36
+	 * @var boolean $ajax
37
+	 */
38
+	public $ajax = false;
39
+
40
+	/**
41
+	 * whether current request is via AJAX from the frontend of the site
42
+	 *
43
+	 * @var boolean $front_ajax
44
+	 */
45
+	public $front_ajax = false;
46
+
47
+
48
+	/**
49
+	 * @deprecated 4.9.53
50
+	 * @param array $get
51
+	 * @param array $post
52
+	 * @param array $cookie
53
+	 * @param array $server
54
+	 */
55
+	public function __construct(
56
+		array $get = array(),
57
+		array $post = array(),
58
+		array $cookie = array(),
59
+		array $server = array()
60
+	) {
61
+	}
62
+
63
+
64
+	/**
65
+	 * @return RequestInterface
66
+	 * @throws InvalidArgumentException
67
+	 * @throws InvalidInterfaceException
68
+	 * @throws InvalidDataTypeException
69
+	 */
70
+	private function request()
71
+	{
72
+		if ($this->request instanceof RequestInterface) {
73
+			return $this->request;
74
+		}
75
+		$loader = LoaderFactory::getLoader();
76
+		$this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface');
77
+		return $this->request;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @param RequestInterface $request
83
+	 */
84
+	public function setRequest(RequestInterface $request)
85
+	{
86
+		$this->request = $request;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @deprecated 4.9.53
92
+	 * @return array
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidDataTypeException
95
+	 * @throws InvalidInterfaceException
96
+	 */
97
+	public function get_params()
98
+	{
99
+		return $this->request()->getParams();
100
+	}
101
+
102
+
103
+	/**
104
+	 * @deprecated 4.9.53
105
+	 * @return array
106
+	 * @throws InvalidArgumentException
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 */
110
+	public function post_params()
111
+	{
112
+		return $this->request()->postParams();
113
+	}
114
+
115
+
116
+	/**
117
+	 * @deprecated 4.9.53
118
+	 * @return array
119
+	 * @throws InvalidArgumentException
120
+	 * @throws InvalidDataTypeException
121
+	 * @throws InvalidInterfaceException
122
+	 */
123
+	public function cookie_params()
124
+	{
125
+		return $this->request()->cookieParams();
126
+	}
127
+
128
+
129
+	/**
130
+	 * @deprecated 4.9.53
131
+	 * @return array
132
+	 * @throws InvalidArgumentException
133
+	 * @throws InvalidDataTypeException
134
+	 * @throws InvalidInterfaceException
135
+	 */
136
+	public function server_params()
137
+	{
138
+		return $this->request()->serverParams();
139
+	}
140
+
141
+
142
+	/**
143
+	 * returns contents of $_REQUEST
144
+	 *
145
+	 * @deprecated 4.9.53
146
+	 * @return array
147
+	 * @throws InvalidArgumentException
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidInterfaceException
150
+	 */
151
+	public function params()
152
+	{
153
+		return $this->request()->requestParams();
154
+	}
155
+
156
+
157
+	/**
158
+	 * @deprecated 4.9.53
159
+	 * @param      $key
160
+	 * @param      $value
161
+	 * @param bool $override_ee
162
+	 * @return void
163
+	 * @throws InvalidArgumentException
164
+	 * @throws InvalidDataTypeException
165
+	 * @throws InvalidInterfaceException
166
+	 */
167
+	public function set($key, $value, $override_ee = false)
168
+	{
169
+		$this->request()->setRequestParam($key, $value, $override_ee);
170
+	}
171
+
172
+
173
+	/**
174
+	 * returns   the value for a request param if the given key exists
175
+	 *
176
+	 * @deprecated 4.9.53
177
+	 * @param      $key
178
+	 * @param null $default
179
+	 * @return mixed
180
+	 * @throws InvalidArgumentException
181
+	 * @throws InvalidDataTypeException
182
+	 * @throws InvalidInterfaceException
183
+	 */
184
+	public function get($key, $default = null)
185
+	{
186
+		return $this->request()->getRequestParam($key, $default);
187
+	}
188
+
189
+
190
+	/**
191
+	 * check if param exists
192
+	 *
193
+	 * @deprecated 4.9.53
194
+	 * @param $key
195
+	 * @return bool
196
+	 * @throws InvalidArgumentException
197
+	 * @throws InvalidDataTypeException
198
+	 * @throws InvalidInterfaceException
199
+	 */
200
+	public function is_set($key)
201
+	{
202
+		return $this->request()->requestParamIsSet($key);
203
+	}
204
+
205
+
206
+	/**
207
+	 * remove param
208
+	 *
209
+	 * @deprecated 4.9.53
210
+	 * @param      $key
211
+	 * @param bool $unset_from_global_too
212
+	 * @throws InvalidArgumentException
213
+	 * @throws InvalidDataTypeException
214
+	 * @throws InvalidInterfaceException
215
+	 */
216
+	public function un_set($key, $unset_from_global_too = false)
217
+	{
218
+		$this->request()->unSetRequestParam($key, $unset_from_global_too);
219
+	}
220
+
221
+
222
+	/**
223
+	 * @deprecated 4.9.53
224
+	 * @return string
225
+	 * @throws InvalidArgumentException
226
+	 * @throws InvalidDataTypeException
227
+	 * @throws InvalidInterfaceException
228
+	 */
229
+	public function ip_address()
230
+	{
231
+		return $this->request()->ipAddress();
232
+	}
233
+
234
+
235
+	/**
236
+	 * @deprecated 4.9.53
237
+	 * @return bool
238
+	 * @throws InvalidArgumentException
239
+	 * @throws InvalidDataTypeException
240
+	 * @throws InvalidInterfaceException
241
+	 */
242
+	public function isAdmin()
243
+	{
244
+		return $this->request()->isAdmin();
245
+	}
246
+
247
+
248
+	/**
249
+	 * @deprecated 4.9.53
250
+	 * @return mixed
251
+	 * @throws InvalidArgumentException
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws InvalidInterfaceException
254
+	 */
255
+	public function isAjax()
256
+	{
257
+		return $this->request()->isAjax();
258
+	}
259
+
260
+
261
+	/**
262
+	 * @deprecated 4.9.53
263
+	 * @return mixed
264
+	 * @throws InvalidArgumentException
265
+	 * @throws InvalidDataTypeException
266
+	 * @throws InvalidInterfaceException
267
+	 */
268
+	public function isFrontAjax()
269
+	{
270
+		return $this->request()->isFrontAjax();
271
+	}
272
+
273
+
274
+	/**
275
+	 * @deprecated 4.9.53
276
+	 * @return mixed|string
277
+	 * @throws InvalidArgumentException
278
+	 * @throws InvalidDataTypeException
279
+	 * @throws InvalidInterfaceException
280
+	 */
281
+	public function requestUri()
282
+	{
283
+		return $this->request()->requestUri();
284
+	}
285
+
286
+
287
+	/**
288
+	 * @deprecated 4.9.53
289
+	 * @return string
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidDataTypeException
292
+	 * @throws InvalidInterfaceException
293
+	 */
294
+	public function userAgent()
295
+	{
296
+		return $this->request()->userAgent();
297
+	}
298
+
299
+
300
+	/**
301
+	 * @deprecated 4.9.53
302
+	 * @param string $user_agent
303
+	 * @throws InvalidArgumentException
304
+	 * @throws InvalidDataTypeException
305
+	 * @throws InvalidInterfaceException
306
+	 */
307
+	public function setUserAgent($user_agent = '')
308
+	{
309
+		$this->request()->setUserAgent($user_agent);
310
+	}
311
+
312
+
313
+	/**
314
+	 * @deprecated 4.9.53
315
+	 * @return bool
316
+	 * @throws InvalidArgumentException
317
+	 * @throws InvalidDataTypeException
318
+	 * @throws InvalidInterfaceException
319
+	 */
320
+	public function isBot()
321
+	{
322
+		return $this->request()->isBot();
323
+	}
324
+
325
+
326
+	/**
327
+	 * @deprecated 4.9.53
328
+	 * @param bool $is_bot
329
+	 * @throws InvalidArgumentException
330
+	 * @throws InvalidDataTypeException
331
+	 * @throws InvalidInterfaceException
332
+	 */
333
+	public function setIsBot($is_bot)
334
+	{
335
+		$this->request()->setIsBot($is_bot);
336
+	}
337
+
338
+
339
+	/**
340
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
341
+	 * and return the value for the first match found
342
+	 * wildcards can be either of the following:
343
+	 *      ? to represent a single character of any type
344
+	 *      * to represent one or more characters of any type
345
+	 *
346
+	 * @param string     $pattern
347
+	 * @param null|mixed $default
348
+	 * @return false|int
349
+	 * @throws InvalidArgumentException
350
+	 * @throws InvalidInterfaceException
351
+	 * @throws InvalidDataTypeException
352
+	 */
353
+	public function getMatch($pattern, $default = null)
354
+	{
355
+		return $this->request()->getMatch($pattern, $default);
356
+	}
357
+
358
+
359
+	/**
360
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
361
+	 * wildcards can be either of the following:
362
+	 *      ? to represent a single character of any type
363
+	 *      * to represent one or more characters of any type
364
+	 * returns true if a match is found or false if not
365
+	 *
366
+	 * @param string $pattern
367
+	 * @return false|int
368
+	 * @throws InvalidArgumentException
369
+	 * @throws InvalidInterfaceException
370
+	 * @throws InvalidDataTypeException
371
+	 */
372
+	public function matches($pattern)
373
+	{
374
+		return $this->request()->matches($pattern);
375
+	}
376 376
 }
Please login to merge, or discard this patch.
core/domain/services/contexts/RequestTypeContextCheckerInterface.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -14,115 +14,115 @@
 block discarded – undo
14 14
 interface RequestTypeContextCheckerInterface
15 15
 {
16 16
 
17
-    /**
18
-     * true if the current request involves some form of activation
19
-     *
20
-     * @return bool
21
-     */
22
-    public function isActivation();
17
+	/**
18
+	 * true if the current request involves some form of activation
19
+	 *
20
+	 * @return bool
21
+	 */
22
+	public function isActivation();
23 23
 
24 24
 
25
-    /**
26
-     * @param $is_activation
27
-     * @return bool
28
-     */
29
-    public function setIsActivation($is_activation);
25
+	/**
26
+	 * @param $is_activation
27
+	 * @return bool
28
+	 */
29
+	public function setIsActivation($is_activation);
30 30
 
31 31
 
32
-    /**
33
-     * true if the current request is for the admin and is not being made via AJAX
34
-     *
35
-     * @return bool
36
-     */
37
-    public function isAdmin();
32
+	/**
33
+	 * true if the current request is for the admin and is not being made via AJAX
34
+	 *
35
+	 * @return bool
36
+	 */
37
+	public function isAdmin();
38 38
 
39 39
 
40
-    /**
41
-     * true if the current request is for the admin AND is being made via AJAX
42
-     *
43
-     * @return bool
44
-     */
45
-    public function isAdminAjax();
40
+	/**
41
+	 * true if the current request is for the admin AND is being made via AJAX
42
+	 *
43
+	 * @return bool
44
+	 */
45
+	public function isAdminAjax();
46 46
 
47 47
 
48
-    /**
49
-     * true if the current request is being made via AJAX... any AJAX
50
-     *
51
-     * @return bool
52
-     */
53
-    public function isAjax();
48
+	/**
49
+	 * true if the current request is being made via AJAX... any AJAX
50
+	 *
51
+	 * @return bool
52
+	 */
53
+	public function isAjax();
54 54
 
55 55
 
56
-    /**
57
-     * true if the current request is for the EE REST API
58
-     *
59
-     * @return bool
60
-     */
61
-    public function isApi();
56
+	/**
57
+	 * true if the current request is for the EE REST API
58
+	 *
59
+	 * @return bool
60
+	 */
61
+	public function isApi();
62 62
 
63 63
 
64
-    /**
65
-     * true if the current request is from the command line
66
-     *
67
-     * @return bool
68
-     */
69
-    public function isCli();
64
+	/**
65
+	 * true if the current request is from the command line
66
+	 *
67
+	 * @return bool
68
+	 */
69
+	public function isCli();
70 70
 
71 71
 
72
-    /**
73
-     * true if the current request is for a WP_Cron
74
-     *
75
-     * @return bool
76
-     */
77
-    public function isCron();
72
+	/**
73
+	 * true if the current request is for a WP_Cron
74
+	 *
75
+	 * @return bool
76
+	 */
77
+	public function isCron();
78 78
 
79 79
 
80
-    /**
81
-     * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
82
-     *
83
-     * @return bool
84
-     */
85
-    public function isEeAjax();
80
+	/**
81
+	 * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX
82
+	 *
83
+	 * @return bool
84
+	 */
85
+	public function isEeAjax();
86 86
 
87 87
 
88
-    /**
89
-     * true if the current request is for a feed (ie: RSS)
90
-     *
91
-     * @return bool
92
-     */
93
-    public function isFeed();
88
+	/**
89
+	 * true if the current request is for a feed (ie: RSS)
90
+	 *
91
+	 * @return bool
92
+	 */
93
+	public function isFeed();
94 94
 
95 95
 
96
-    /**
97
-     * true if the current request is for the frontend and is not being made via AJAX
98
-     *
99
-     * @return bool
100
-     */
101
-    public function isFrontend();
96
+	/**
97
+	 * true if the current request is for the frontend and is not being made via AJAX
98
+	 *
99
+	 * @return bool
100
+	 */
101
+	public function isFrontend();
102 102
 
103 103
 
104
-    /**
105
-     * @return bool
106
-     */
107
-    public function isFrontAjax();
104
+	/**
105
+	 * @return bool
106
+	 */
107
+	public function isFrontAjax();
108 108
 
109 109
 
110
-    /**
111
-     * @return bool
112
-     */
113
-    public function isIframe();
110
+	/**
111
+	 * @return bool
112
+	 */
113
+	public function isIframe();
114 114
 
115 115
 
116
-    /**
117
-     * true if the current request is being made via AJAX but is NOT for EE related logic
118
-     *
119
-     * @return bool
120
-     */
121
-    public function isOtherAjax();
116
+	/**
117
+	 * true if the current request is being made via AJAX but is NOT for EE related logic
118
+	 *
119
+	 * @return bool
120
+	 */
121
+	public function isOtherAjax();
122 122
 
123 123
 
124
-    /**
125
-     * @return string
126
-     */
127
-    public function slug();
124
+	/**
125
+	 * @return string
126
+	 */
127
+	public function slug();
128 128
 }
Please login to merge, or discard this patch.
core/services/request/RequestStack.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -19,59 +19,59 @@
 block discarded – undo
19 19
 class RequestStack
20 20
 {
21 21
 
22
-    /**
23
-     * @var RequestDecoratorInterface $request_stack_app
24
-     */
25
-    protected $request_stack_app;
22
+	/**
23
+	 * @var RequestDecoratorInterface $request_stack_app
24
+	 */
25
+	protected $request_stack_app;
26 26
 
27
-    /**
28
-     * @var RequestStackCoreAppInterface $core_app
29
-     */
30
-    protected $core_app;
27
+	/**
28
+	 * @var RequestStackCoreAppInterface $core_app
29
+	 */
30
+	protected $core_app;
31 31
 
32
-    /**
33
-     * @var RequestInterface $request
34
-     */
35
-    protected $request;
32
+	/**
33
+	 * @var RequestInterface $request
34
+	 */
35
+	protected $request;
36 36
 
37
-    /**
38
-     * @var ResponseInterface $response
39
-     */
40
-    protected $response;
37
+	/**
38
+	 * @var ResponseInterface $response
39
+	 */
40
+	protected $response;
41 41
 
42 42
 
43
-    /**
44
-     * @param RequestDecoratorInterface    $request_stack_app
45
-     * @param RequestStackCoreAppInterface $core_app
46
-     */
47
-    public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48
-    {
49
-        $this->request_stack_app = $request_stack_app;
50
-        $this->core_app      = $core_app;
51
-    }
43
+	/**
44
+	 * @param RequestDecoratorInterface    $request_stack_app
45
+	 * @param RequestStackCoreAppInterface $core_app
46
+	 */
47
+	public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48
+	{
49
+		$this->request_stack_app = $request_stack_app;
50
+		$this->core_app      = $core_app;
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * @param RequestInterface  $request
56
-     * @param ResponseInterface $response
57
-     * @return ResponseInterface
58
-     */
59
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
60
-    {
61
-        $this->request  = $request;
62
-        $this->response = $response;
63
-        return $this->request_stack_app->handleRequest($request, $response);
64
-    }
54
+	/**
55
+	 * @param RequestInterface  $request
56
+	 * @param ResponseInterface $response
57
+	 * @return ResponseInterface
58
+	 */
59
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
60
+	{
61
+		$this->request  = $request;
62
+		$this->response = $response;
63
+		return $this->request_stack_app->handleRequest($request, $response);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * handle_response
69
-     * executes the handle_response() method on the RequestStackCoreAppInterface object
70
-     * after the request stack has been fully processed
71
-     */
72
-    public function handleResponse()
73
-    {
74
-        $this->core_app->handleResponse($this->request, $this->response);
75
-    }
67
+	/**
68
+	 * handle_response
69
+	 * executes the handle_response() method on the RequestStackCoreAppInterface object
70
+	 * after the request stack has been fully processed
71
+	 */
72
+	public function handleResponse()
73
+	{
74
+		$this->core_app->handleResponse($this->request, $this->response);
75
+	}
76 76
 }
77 77
 // Location: RequestStack.php
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app)
48 48
     {
49 49
         $this->request_stack_app = $request_stack_app;
50
-        $this->core_app      = $core_app;
50
+        $this->core_app = $core_app;
51 51
     }
52 52
 
53 53
 
Please login to merge, or discard this patch.
core/services/request/middleware/SetRequestTypeContextChecker.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -22,36 +22,36 @@
 block discarded – undo
22 22
 class SetRequestTypeContextChecker extends Middleware
23 23
 {
24 24
 
25
-    /**
26
-     * converts a Request to a Response
27
-     *
28
-     * @param RequestInterface  $request
29
-     * @param ResponseInterface $response
30
-     * @return ResponseInterface
31
-     * @throws InvalidArgumentException
32
-     */
33
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
34
-    {
35
-        $this->request  = $request;
36
-        $this->response = $response;
37
-        /** @var RequestTypeContextDetector $request_type_context_detector */
38
-        $request_type_context_detector = $this->loader->getShared(
39
-            'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector',
40
-            array(
41
-                $this->request,
42
-                $this->loader->getShared(
43
-                    'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory',
44
-                    array($this->loader)
45
-                ),
46
-            )
47
-        );
48
-        $request_type_context          = $request_type_context_detector->detectRequestTypeContext();
49
-        $request_type_context_checker  = $this->loader->getShared(
50
-            'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker',
51
-            array($request_type_context)
52
-        );
53
-        $this->request->setRequestTypeContextChecker($request_type_context_checker);
54
-        $this->response = $this->processRequestStack($this->request, $this->response);
55
-        return $this->response;
56
-    }
25
+	/**
26
+	 * converts a Request to a Response
27
+	 *
28
+	 * @param RequestInterface  $request
29
+	 * @param ResponseInterface $response
30
+	 * @return ResponseInterface
31
+	 * @throws InvalidArgumentException
32
+	 */
33
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
34
+	{
35
+		$this->request  = $request;
36
+		$this->response = $response;
37
+		/** @var RequestTypeContextDetector $request_type_context_detector */
38
+		$request_type_context_detector = $this->loader->getShared(
39
+			'EventEspresso\core\domain\services\contexts\RequestTypeContextDetector',
40
+			array(
41
+				$this->request,
42
+				$this->loader->getShared(
43
+					'EventEspresso\core\domain\services\contexts\RequestTypeContextFactory',
44
+					array($this->loader)
45
+				),
46
+			)
47
+		);
48
+		$request_type_context          = $request_type_context_detector->detectRequestTypeContext();
49
+		$request_type_context_checker  = $this->loader->getShared(
50
+			'EventEspresso\core\domain\services\contexts\RequestTypeContextChecker',
51
+			array($request_type_context)
52
+		);
53
+		$this->request->setRequestTypeContextChecker($request_type_context_checker);
54
+		$this->response = $this->processRequestStack($this->request, $this->response);
55
+		return $this->response;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/services/collections/iterators/CollectionFilterCallbackIterator.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -9,51 +9,51 @@
 block discarded – undo
9 9
 class CollectionFilterCallbackIterator extends FilterIterator
10 10
 {
11 11
 
12
-    /**
13
-     * Used for determining whether the iterated object in the Collection is "valid" or not.
14
-     * @var Closure
15
-     */
16
-    private $acceptance_callback;
17
-
18
-
19
-    /**
20
-     * CollectionFilterCallbackIterator constructor.
21
-     *
22
-     * @param Collection $collection
23
-     * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
-     *                                         collection when iterating over the collection and should return boolean.
25
-     */
26
-    public function __construct(Collection $collection, Closure $acceptance_callback)
27
-    {
28
-        $this->acceptance_callback = $acceptance_callback;
29
-        parent::__construct($collection);
30
-    }
31
-
32
-    /**
33
-     * Check whether the current element of the iterator is acceptable
34
-     *
35
-     * @link  http://php.net/manual/en/filteriterator.accept.php
36
-     * @return bool true if the current element is acceptable, otherwise false.
37
-     */
38
-    public function accept()
39
-    {
40
-        $acceptance_callback = $this->acceptance_callback;
41
-        return $acceptance_callback($this->getInnerIterator()->current());
42
-    }
43
-
44
-
45
-
46
-    /**
47
-     * Returns a filtered array of objects from the collection using the provided acceptance callback
48
-     * @return array
49
-     */
50
-    public function getFiltered()
51
-    {
52
-        $filtered_array = array();
53
-        $this->rewind();
54
-        foreach ($this as $filtered_object) {
55
-            $filtered_array[] = $filtered_object;
56
-        }
57
-        return $filtered_array;
58
-    }
12
+	/**
13
+	 * Used for determining whether the iterated object in the Collection is "valid" or not.
14
+	 * @var Closure
15
+	 */
16
+	private $acceptance_callback;
17
+
18
+
19
+	/**
20
+	 * CollectionFilterCallbackIterator constructor.
21
+	 *
22
+	 * @param Collection $collection
23
+	 * @param Closure    $acceptance_callback  The closure will receive an instance of whatever object is stored on the
24
+	 *                                         collection when iterating over the collection and should return boolean.
25
+	 */
26
+	public function __construct(Collection $collection, Closure $acceptance_callback)
27
+	{
28
+		$this->acceptance_callback = $acceptance_callback;
29
+		parent::__construct($collection);
30
+	}
31
+
32
+	/**
33
+	 * Check whether the current element of the iterator is acceptable
34
+	 *
35
+	 * @link  http://php.net/manual/en/filteriterator.accept.php
36
+	 * @return bool true if the current element is acceptable, otherwise false.
37
+	 */
38
+	public function accept()
39
+	{
40
+		$acceptance_callback = $this->acceptance_callback;
41
+		return $acceptance_callback($this->getInnerIterator()->current());
42
+	}
43
+
44
+
45
+
46
+	/**
47
+	 * Returns a filtered array of objects from the collection using the provided acceptance callback
48
+	 * @return array
49
+	 */
50
+	public function getFiltered()
51
+	{
52
+		$filtered_array = array();
53
+		$this->rewind();
54
+		foreach ($this as $filtered_object) {
55
+			$filtered_array[] = $filtered_object;
56
+		}
57
+		return $filtered_array;
58
+	}
59 59
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Aim/EEG_Aim.gateway.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -362,7 +362,7 @@
 block discarded – undo
362 362
     /**
363 363
      * Posts the request to AuthorizeNet & returns response.
364 364
      *
365
-     * @param $payment
365
+     * @param EEI_Payment $payment
366 366
      * @return \EE_AuthorizeNetAIM_Response
367 367
      */
368 368
     private function _sendRequest($payment)
Please login to merge, or discard this patch.
Indentation   +602 added lines, -602 removed lines patch added patch discarded remove patch
@@ -23,424 +23,424 @@  discard block
 block discarded – undo
23 23
 class EEG_Aim extends EE_Onsite_Gateway
24 24
 {
25 25
 
26
-    const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
27
-
28
-    const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
29
-
30
-    protected $_login_id;
31
-
32
-    protected $_transaction_key;
33
-
34
-    protected $_server;
35
-
36
-    protected $_currencies_supported = array(
37
-        'AUD',
38
-        'USD',
39
-        'CAD',
40
-        'EUR',
41
-        'GBP',
42
-        'NZD',
43
-    );
44
-
45
-    /**
46
-     * Whether to send test transactions (even to live site)
47
-     *
48
-     * @var boolean
49
-     */
50
-    protected $_test_transactions;
51
-
52
-    private $VERIFY_PEER = false;
53
-
54
-    private $_x_post_fields = array(
55
-        "version"        => "3.1",
56
-        "delim_char"     => ",",
57
-        "delim_data"     => "TRUE",
58
-        "relay_response" => "FALSE",
59
-        "encap_char"     => "|",
60
-    );
61
-
62
-    private $_additional_line_items = array();
63
-
64
-    /**
65
-     * A list of all fields in the AIM API.
66
-     * Used to warn user if they try to set a field not offered in the API.
67
-     */
68
-    private $_all_aim_fields = array(
69
-        "address",
70
-        "allow_partial_auth",
71
-        "amount",
72
-        "auth_code",
73
-        "authentication_indicator",
74
-        "bank_aba_code",
75
-        "bank_acct_name",
76
-        "bank_acct_num",
77
-        "bank_acct_type",
78
-        "bank_check_number",
79
-        "bank_name",
80
-        "card_code",
81
-        "card_num",
82
-        "cardholder_authentication_value",
83
-        "city",
84
-        "company",
85
-        "country",
86
-        "cust_id",
87
-        "customer_ip",
88
-        "delim_char",
89
-        "delim_data",
90
-        "description",
91
-        "duplicate_window",
92
-        "duty",
93
-        "echeck_type",
94
-        "email",
95
-        "email_customer",
96
-        "encap_char",
97
-        "exp_date",
98
-        "fax",
99
-        "first_name",
100
-        "footer_email_receipt",
101
-        "freight",
102
-        "header_email_receipt",
103
-        "invoice_num",
104
-        "last_name",
105
-        "line_item",
106
-        "login",
107
-        "method",
108
-        "phone",
109
-        "po_num",
110
-        "recurring_billing",
111
-        "relay_response",
112
-        "ship_to_address",
113
-        "ship_to_city",
114
-        "ship_to_company",
115
-        "ship_to_country",
116
-        "ship_to_first_name",
117
-        "ship_to_last_name",
118
-        "ship_to_state",
119
-        "ship_to_zip",
120
-        "split_tender_id",
121
-        "state",
122
-        "tax",
123
-        "tax_exempt",
124
-        "test_request",
125
-        "tran_key",
126
-        "trans_id",
127
-        "type",
128
-        "version",
129
-        "zip",
130
-        "solution_id"
131
-    );
132
-
133
-
134
-    /**
135
-     * Gets the URL where the request should go. This is filterable
136
-     *
137
-     * @return string
138
-     */
139
-    protected function _get_server_url()
140
-    {
141
-        return apply_filters(
142
-            'FHEE__EEG_Aim___get_server_url',
143
-            $this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
144
-            $this
145
-        );
146
-    }
147
-
148
-
149
-    /**
150
-     * TEMPORARY CALLBACK! Do not use
151
-     * Callback which filters the server url. This is added so site admins can revert to using
152
-     * the old AIM server in case Akamai service breaks their integration.
153
-     * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net
154
-     * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343)
155
-     * Once that happens, this will be obsolete and WILL BE REMOVED.
156
-     *
157
-     * @param string $url
158
-     * @param EEG_Aim $gateway_object
159
-     * @return string
160
-     */
161
-    public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object)
162
-    {
163
-        if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) {
164
-            return 'https://secure.authorize.net/gateway/transact.dll';
165
-        } else {
166
-            return $url;
167
-        }
168
-    }
169
-
170
-
171
-    /**
172
-     * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
173
-     * usually send a request directly to the payment provider and update the payment's status based on that;
174
-     * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
175
-     * for sending the request via http_remote_request()
176
-     *
177
-     * @param EEI_Payment $payment
178
-     * @param array $billing_info {
179
-     *  @type $credit_card string
180
-     *  @type $cvv string
181
-     *  @type $exp_month string
182
-     *  @type $exp_year string
183
-     *  @see parent::do_direct_payment
184
-     * }
185
-     * @return EEI_Payment updated
186
-     */
187
-    public function do_direct_payment($payment, $billing_info = null)
188
-    {
189
-        add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
190
-        // Enable test mode if needed
191
-        // 4007000000027  <-- test successful visa
192
-        // 4222222222222  <-- test failure card number
193
-
194
-        $item_num = 1;
195
-        $transaction = $payment->transaction();
196
-        $gateway_formatter = $this->_get_gateway_formatter();
197
-        $order_description = $gateway_formatter->formatOrderDescription($payment);
198
-        $primary_registrant = $transaction->primary_registration();
199
-        // if we're are charging for the full amount, show the normal line items
200
-        // and the itemized total adds up properly
201
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
202
-            $total_line_item = $transaction->total_line_item();
203
-            foreach ($total_line_item->get_items() as $line_item) {
204
-                if ($line_item->quantity() == 0) {
205
-                    continue;
206
-                }
207
-                $this->addLineItem(
208
-                    $item_num++,
209
-                    $gateway_formatter->formatLineItemName($line_item, $payment),
210
-                    $gateway_formatter->formatLineItemDesc($line_item, $payment),
211
-                    $line_item->quantity(),
212
-                    $line_item->unit_price(),
213
-                    'N'
214
-                );
215
-                $order_description .= $line_item->desc().', ';
216
-            }
217
-            foreach ($total_line_item->tax_descendants() as $tax_line_item) {
218
-                $this->addLineItem(
219
-                    $item_num++,
220
-                    $tax_line_item->name(),
221
-                    $tax_line_item->desc(),
222
-                    1,
223
-                    $tax_line_item->total(),
224
-                    'N'
225
-                );
226
-            }
227
-        }
228
-
229
-        // start transaction
230
-        // if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
231
-        $partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
232
-        $this->setField('solution_id', $partner_id);
233
-        $this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
234
-        $this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
235
-        $this->_set_sensitive_billing_data($billing_info);
236
-        $this->setField('first_name', $billing_info['first_name']);
237
-        $this->setField('last_name', $billing_info['last_name']);
238
-        $this->setField('email', $billing_info['email']);
239
-        $this->setField('company', $billing_info['company']);
240
-        $this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
241
-        $this->setField('city', $billing_info['city']);
242
-        $this->setField('state', $billing_info['state']);
243
-        $this->setField('country', $billing_info['country']);
244
-        $this->setField('zip', $billing_info['zip']);
245
-        $this->setField('fax', $billing_info['fax']);
246
-        $this->setField('cust_id', $primary_registrant->ID());
247
-        $this->setField('phone', $billing_info['phone']);
248
-        // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
249
-        // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
250
-        // in which case, we need to generate teh invoice num per request right here...
251
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
252
-        // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
253
-        $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
254
-
255
-        if ($this->_test_transactions) {
256
-            $this->test_request = "true";
257
-        }
258
-
259
-        // Capture response
260
-        $this->type = "AUTH_CAPTURE";
261
-        $response = $this->_sendRequest($payment);
262
-        if (! empty($response)) {
263
-            if ($response->error_message) {
264
-                $payment->set_status($this->_pay_model->failed_status());
265
-                $payment->set_gateway_response($response->error_message);
266
-            } else {
267
-                $payment_status = $response->approved
268
-                    ? $this->_pay_model->approved_status()
269
-                    : $this->_pay_model->declined_status();
270
-                $payment->set_status($payment_status);
271
-                // make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
272
-                $payment->set_amount((float) $response->amount);
273
-                $payment->set_gateway_response(
274
-                    sprintf(
275
-                        esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
276
-                        $response->response_reason_text,
277
-                        $response->response_reason_code
278
-                    )
279
-                );
280
-                if ($this->_debug_mode) {
281
-                    $txn_id = $response->invoice_number;
282
-                } else {
283
-                    $txn_id = $response->transaction_id;
284
-                }
285
-                $payment->set_txn_id_chq_nmbr($txn_id);
286
-            }
287
-            $payment->set_extra_accntng($primary_registrant->reg_code());
288
-            $payment->set_details(print_r($response, true));
289
-        } else {
290
-            $payment->set_status($this->_pay_model->failed_status());
291
-            $payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
292
-            $payment->set_details(print_r($response, true));
293
-        }
294
-        return $payment;
295
-    }
296
-
297
-
298
-    /**
299
-     * Sets billing data for the upcoming request to AIM that is considered sensitive;
300
-     * also this method can be overridden by children classes to easily change
301
-     * what billing data gets sent
302
-     *
303
-     * @param array $billing_info
304
-     */
305
-    protected function _set_sensitive_billing_data($billing_info)
306
-    {
307
-        $this->setField('card_num', $billing_info['credit_card']);
308
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
309
-        $this->setField('card_code', $billing_info['cvv']);
310
-    }
311
-
312
-
313
-    /**
314
-     * Add a line item.
315
-     *
316
-     * @param string $item_id
317
-     * @param string $item_name
318
-     * @param string $item_description
319
-     * @param string $item_quantity
320
-     * @param string $item_unit_price
321
-     * @param string $item_taxable
322
-     */
323
-    public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
324
-    {
325
-        $args = array(
326
-            substr($item_id, 0, 31),
327
-            substr($item_name, 0, 31),
328
-            substr($item_description, 0, 255),
329
-            number_format(abs($item_quantity), 2, '.', ''),
330
-            number_format(abs($item_unit_price), 2, '.', ''),
331
-            $item_taxable === 'N' ? 'N' : 'Y'
332
-        );
333
-        $this->_additional_line_items[] = implode('<|>', $args);
334
-    }
335
-
336
-
337
-    /**
338
-     * Set an individual name/value pair. This will append x_ to the name
339
-     * before posting.
340
-     *
341
-     * @param string $name
342
-     * @param string $value
343
-     * @throws AuthorizeNetException
344
-     */
345
-    protected function setField($name, $value)
346
-    {
347
-        if (in_array($name, $this->_all_aim_fields)) {
348
-            $this->_x_post_fields[ $name ] = $value;
349
-        } else {
350
-            throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
26
+	const LIVE_URL    = 'https://secure2.authorize.net/gateway/transact.dll'; // Authnet URL
27
+
28
+	const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
29
+
30
+	protected $_login_id;
31
+
32
+	protected $_transaction_key;
33
+
34
+	protected $_server;
35
+
36
+	protected $_currencies_supported = array(
37
+		'AUD',
38
+		'USD',
39
+		'CAD',
40
+		'EUR',
41
+		'GBP',
42
+		'NZD',
43
+	);
44
+
45
+	/**
46
+	 * Whether to send test transactions (even to live site)
47
+	 *
48
+	 * @var boolean
49
+	 */
50
+	protected $_test_transactions;
51
+
52
+	private $VERIFY_PEER = false;
53
+
54
+	private $_x_post_fields = array(
55
+		"version"        => "3.1",
56
+		"delim_char"     => ",",
57
+		"delim_data"     => "TRUE",
58
+		"relay_response" => "FALSE",
59
+		"encap_char"     => "|",
60
+	);
61
+
62
+	private $_additional_line_items = array();
63
+
64
+	/**
65
+	 * A list of all fields in the AIM API.
66
+	 * Used to warn user if they try to set a field not offered in the API.
67
+	 */
68
+	private $_all_aim_fields = array(
69
+		"address",
70
+		"allow_partial_auth",
71
+		"amount",
72
+		"auth_code",
73
+		"authentication_indicator",
74
+		"bank_aba_code",
75
+		"bank_acct_name",
76
+		"bank_acct_num",
77
+		"bank_acct_type",
78
+		"bank_check_number",
79
+		"bank_name",
80
+		"card_code",
81
+		"card_num",
82
+		"cardholder_authentication_value",
83
+		"city",
84
+		"company",
85
+		"country",
86
+		"cust_id",
87
+		"customer_ip",
88
+		"delim_char",
89
+		"delim_data",
90
+		"description",
91
+		"duplicate_window",
92
+		"duty",
93
+		"echeck_type",
94
+		"email",
95
+		"email_customer",
96
+		"encap_char",
97
+		"exp_date",
98
+		"fax",
99
+		"first_name",
100
+		"footer_email_receipt",
101
+		"freight",
102
+		"header_email_receipt",
103
+		"invoice_num",
104
+		"last_name",
105
+		"line_item",
106
+		"login",
107
+		"method",
108
+		"phone",
109
+		"po_num",
110
+		"recurring_billing",
111
+		"relay_response",
112
+		"ship_to_address",
113
+		"ship_to_city",
114
+		"ship_to_company",
115
+		"ship_to_country",
116
+		"ship_to_first_name",
117
+		"ship_to_last_name",
118
+		"ship_to_state",
119
+		"ship_to_zip",
120
+		"split_tender_id",
121
+		"state",
122
+		"tax",
123
+		"tax_exempt",
124
+		"test_request",
125
+		"tran_key",
126
+		"trans_id",
127
+		"type",
128
+		"version",
129
+		"zip",
130
+		"solution_id"
131
+	);
132
+
133
+
134
+	/**
135
+	 * Gets the URL where the request should go. This is filterable
136
+	 *
137
+	 * @return string
138
+	 */
139
+	protected function _get_server_url()
140
+	{
141
+		return apply_filters(
142
+			'FHEE__EEG_Aim___get_server_url',
143
+			$this->_debug_mode ? self::SANDBOX_URL : self::LIVE_URL,
144
+			$this
145
+		);
146
+	}
147
+
148
+
149
+	/**
150
+	 * TEMPORARY CALLBACK! Do not use
151
+	 * Callback which filters the server url. This is added so site admins can revert to using
152
+	 * the old AIM server in case Akamai service breaks their integration.
153
+	 * Using Akamai will, however, be mandatory on June 30th 2016 Authorize.net
154
+	 * (see http://www.authorize.net/support/akamaifaqs/#firewall?utm_campaign=April%202016%20Technical%20Updates%20for%20Merchants.html&utm_medium=email&utm_source=Eloqua&elqTrackId=46103bdc375c411a979c2f658fc99074&elq=7026706360154fee9b6d588b27d8eb6a&elqaid=506&elqat=1&elqCampaignId=343)
155
+	 * Once that happens, this will be obsolete and WILL BE REMOVED.
156
+	 *
157
+	 * @param string $url
158
+	 * @param EEG_Aim $gateway_object
159
+	 * @return string
160
+	 */
161
+	public function possibly_use_deprecated_aim_server($url, EEG_Aim $gateway_object)
162
+	{
163
+		if ($gateway_object->_server === 'authorize.net' && ! $gateway_object->_debug_mode) {
164
+			return 'https://secure.authorize.net/gateway/transact.dll';
165
+		} else {
166
+			return $url;
167
+		}
168
+	}
169
+
170
+
171
+	/**
172
+	 * Asks the gateway to do whatever it does to process the payment. Onsite gateways will
173
+	 * usually send a request directly to the payment provider and update the payment's status based on that;
174
+	 * whereas offsite gateways will usually just update the payment with the URL and query parameters to use
175
+	 * for sending the request via http_remote_request()
176
+	 *
177
+	 * @param EEI_Payment $payment
178
+	 * @param array $billing_info {
179
+	 *  @type $credit_card string
180
+	 *  @type $cvv string
181
+	 *  @type $exp_month string
182
+	 *  @type $exp_year string
183
+	 *  @see parent::do_direct_payment
184
+	 * }
185
+	 * @return EEI_Payment updated
186
+	 */
187
+	public function do_direct_payment($payment, $billing_info = null)
188
+	{
189
+		add_filter('FHEE__EEG_Aim___get_server_url', array($this, 'possibly_use_deprecated_aim_server'), 10, 2);
190
+		// Enable test mode if needed
191
+		// 4007000000027  <-- test successful visa
192
+		// 4222222222222  <-- test failure card number
193
+
194
+		$item_num = 1;
195
+		$transaction = $payment->transaction();
196
+		$gateway_formatter = $this->_get_gateway_formatter();
197
+		$order_description = $gateway_formatter->formatOrderDescription($payment);
198
+		$primary_registrant = $transaction->primary_registration();
199
+		// if we're are charging for the full amount, show the normal line items
200
+		// and the itemized total adds up properly
201
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
202
+			$total_line_item = $transaction->total_line_item();
203
+			foreach ($total_line_item->get_items() as $line_item) {
204
+				if ($line_item->quantity() == 0) {
205
+					continue;
206
+				}
207
+				$this->addLineItem(
208
+					$item_num++,
209
+					$gateway_formatter->formatLineItemName($line_item, $payment),
210
+					$gateway_formatter->formatLineItemDesc($line_item, $payment),
211
+					$line_item->quantity(),
212
+					$line_item->unit_price(),
213
+					'N'
214
+				);
215
+				$order_description .= $line_item->desc().', ';
216
+			}
217
+			foreach ($total_line_item->tax_descendants() as $tax_line_item) {
218
+				$this->addLineItem(
219
+					$item_num++,
220
+					$tax_line_item->name(),
221
+					$tax_line_item->desc(),
222
+					1,
223
+					$tax_line_item->total(),
224
+					'N'
225
+				);
226
+			}
227
+		}
228
+
229
+		// start transaction
230
+		// if in debug mode, use authorize.net's sandbox id; otherwise use the Event Espresso partner id
231
+		$partner_id = $this->_debug_mode ? 'AAA100302' : 'AAA105363';
232
+		$this->setField('solution_id', $partner_id);
233
+		$this->setField('amount', $gateway_formatter->formatCurrency($payment->amount()));
234
+		$this->setField('description', substr(rtrim($order_description, ', '), 0, 255));
235
+		$this->_set_sensitive_billing_data($billing_info);
236
+		$this->setField('first_name', $billing_info['first_name']);
237
+		$this->setField('last_name', $billing_info['last_name']);
238
+		$this->setField('email', $billing_info['email']);
239
+		$this->setField('company', $billing_info['company']);
240
+		$this->setField('address', $billing_info['address'].' '.$billing_info['address2']);
241
+		$this->setField('city', $billing_info['city']);
242
+		$this->setField('state', $billing_info['state']);
243
+		$this->setField('country', $billing_info['country']);
244
+		$this->setField('zip', $billing_info['zip']);
245
+		$this->setField('fax', $billing_info['fax']);
246
+		$this->setField('cust_id', $primary_registrant->ID());
247
+		$this->setField('phone', $billing_info['phone']);
248
+		// invoice_num would be nice to have it be unique per SPCO page-load, that way if users
249
+		// press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
250
+		// in which case, we need to generate teh invoice num per request right here...
251
+		$this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
252
+		// tell AIM that any duplicates sent in the next 5 minutes are to be ignored
253
+		$this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
254
+
255
+		if ($this->_test_transactions) {
256
+			$this->test_request = "true";
257
+		}
258
+
259
+		// Capture response
260
+		$this->type = "AUTH_CAPTURE";
261
+		$response = $this->_sendRequest($payment);
262
+		if (! empty($response)) {
263
+			if ($response->error_message) {
264
+				$payment->set_status($this->_pay_model->failed_status());
265
+				$payment->set_gateway_response($response->error_message);
266
+			} else {
267
+				$payment_status = $response->approved
268
+					? $this->_pay_model->approved_status()
269
+					: $this->_pay_model->declined_status();
270
+				$payment->set_status($payment_status);
271
+				// make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
272
+				$payment->set_amount((float) $response->amount);
273
+				$payment->set_gateway_response(
274
+					sprintf(
275
+						esc_html__('%1$s (Reason Code: %2$s)', 'event_espresso'),
276
+						$response->response_reason_text,
277
+						$response->response_reason_code
278
+					)
279
+				);
280
+				if ($this->_debug_mode) {
281
+					$txn_id = $response->invoice_number;
282
+				} else {
283
+					$txn_id = $response->transaction_id;
284
+				}
285
+				$payment->set_txn_id_chq_nmbr($txn_id);
286
+			}
287
+			$payment->set_extra_accntng($primary_registrant->reg_code());
288
+			$payment->set_details(print_r($response, true));
289
+		} else {
290
+			$payment->set_status($this->_pay_model->failed_status());
291
+			$payment->set_gateway_response(__("There was no response from Authorize.net", 'event_espresso'));
292
+			$payment->set_details(print_r($response, true));
293
+		}
294
+		return $payment;
295
+	}
296
+
297
+
298
+	/**
299
+	 * Sets billing data for the upcoming request to AIM that is considered sensitive;
300
+	 * also this method can be overridden by children classes to easily change
301
+	 * what billing data gets sent
302
+	 *
303
+	 * @param array $billing_info
304
+	 */
305
+	protected function _set_sensitive_billing_data($billing_info)
306
+	{
307
+		$this->setField('card_num', $billing_info['credit_card']);
308
+		$this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
309
+		$this->setField('card_code', $billing_info['cvv']);
310
+	}
311
+
312
+
313
+	/**
314
+	 * Add a line item.
315
+	 *
316
+	 * @param string $item_id
317
+	 * @param string $item_name
318
+	 * @param string $item_description
319
+	 * @param string $item_quantity
320
+	 * @param string $item_unit_price
321
+	 * @param string $item_taxable
322
+	 */
323
+	public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
324
+	{
325
+		$args = array(
326
+			substr($item_id, 0, 31),
327
+			substr($item_name, 0, 31),
328
+			substr($item_description, 0, 255),
329
+			number_format(abs($item_quantity), 2, '.', ''),
330
+			number_format(abs($item_unit_price), 2, '.', ''),
331
+			$item_taxable === 'N' ? 'N' : 'Y'
332
+		);
333
+		$this->_additional_line_items[] = implode('<|>', $args);
334
+	}
335
+
336
+
337
+	/**
338
+	 * Set an individual name/value pair. This will append x_ to the name
339
+	 * before posting.
340
+	 *
341
+	 * @param string $name
342
+	 * @param string $value
343
+	 * @throws AuthorizeNetException
344
+	 */
345
+	protected function setField($name, $value)
346
+	{
347
+		if (in_array($name, $this->_all_aim_fields)) {
348
+			$this->_x_post_fields[ $name ] = $value;
349
+		} else {
350
+			throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
351 351
             To set a custom field use setCustomField('field','value') instead.");
352
-        }
353
-    }
354
-
355
-
356
-    /**
357
-     * Posts the request to AuthorizeNet & returns response.
358
-     *
359
-     * @param $payment
360
-     * @return \EE_AuthorizeNetAIM_Response
361
-     */
362
-    private function _sendRequest($payment)
363
-    {
364
-        $this->_x_post_fields['login'] = $this->_login_id;
365
-        $this->_x_post_fields['tran_key'] = $this->_transaction_key;
366
-        $x_keys = array();
367
-        foreach ($this->_x_post_fields as $key => $value) {
368
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
369
-        }
370
-        // Add line items
371
-        foreach ($this->_additional_line_items as $key => $value) {
372
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
373
-        }
374
-        $this->_log_clean_request($x_keys, $payment);
375
-        $post_url = $this->_get_server_url();
376
-        $curl_request = curl_init($post_url);
377
-        $post_body = implode("&", $x_keys);
378
-        curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
379
-        curl_setopt($curl_request, CURLOPT_HEADER, 0);
380
-        curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
381
-        curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
382
-        curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
383
-        if ($this->VERIFY_PEER) {
384
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
385
-        } else {
386
-            curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
387
-        }
388
-
389
-        if (preg_match('/xml/', $post_url)) {
390
-            curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
391
-        }
392
-
393
-        $response = curl_exec($curl_request);
394
-
395
-        curl_close($curl_request);
396
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
397
-
398
-        return $this->_log_and_clean_response($response_obj, $payment);
399
-    }
400
-
401
-
402
-    /**
403
-     * Logs the clean data only
404
-     *
405
-     * @param array $request_array
406
-     * @param EEI_Payment $payment
407
-     */
408
-    protected function _log_clean_request($request_array, $payment)
409
-    {
410
-        $keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
411
-        foreach ($request_array as $index => $keyvaltogether) {
412
-            foreach ($keys_to_filter_out as $key) {
413
-                if (strpos($keyvaltogether, $key) === 0) {
414
-                    // found it at the first character
415
-                    // so its one of them
416
-                    unset($request_array[ $index ]);
417
-                }
418
-            }
419
-        }
420
-        $this->log(
421
-            array(
422
-                'AIM Request sent:' => $request_array,
423
-                'Server URL'        => $this->_get_server_url()
424
-            ),
425
-            $payment
426
-        );
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * Logs the response and cleans it
433
-     *
434
-     * @param EE_AuthorizeNetAIM_Response $response_obj
435
-     * @param EE_Payment                  $payment
436
-     * @return \EE_AuthorizeNetAIM_Response
437
-     */
438
-    private function _log_and_clean_response($response_obj, $payment)
439
-    {
440
-        $response_obj->account_number = '';
441
-        $this->log(array('AIM Response received:' => (array) $response_obj), $payment);
442
-        return $response_obj;
443
-    }
352
+		}
353
+	}
354
+
355
+
356
+	/**
357
+	 * Posts the request to AuthorizeNet & returns response.
358
+	 *
359
+	 * @param $payment
360
+	 * @return \EE_AuthorizeNetAIM_Response
361
+	 */
362
+	private function _sendRequest($payment)
363
+	{
364
+		$this->_x_post_fields['login'] = $this->_login_id;
365
+		$this->_x_post_fields['tran_key'] = $this->_transaction_key;
366
+		$x_keys = array();
367
+		foreach ($this->_x_post_fields as $key => $value) {
368
+			$x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
369
+		}
370
+		// Add line items
371
+		foreach ($this->_additional_line_items as $key => $value) {
372
+			$x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
373
+		}
374
+		$this->_log_clean_request($x_keys, $payment);
375
+		$post_url = $this->_get_server_url();
376
+		$curl_request = curl_init($post_url);
377
+		$post_body = implode("&", $x_keys);
378
+		curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post_body);
379
+		curl_setopt($curl_request, CURLOPT_HEADER, 0);
380
+		curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
381
+		curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
382
+		curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
383
+		if ($this->VERIFY_PEER) {
384
+			curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
385
+		} else {
386
+			curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
387
+		}
388
+
389
+		if (preg_match('/xml/', $post_url)) {
390
+			curl_setopt($curl_request, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
391
+		}
392
+
393
+		$response = curl_exec($curl_request);
394
+
395
+		curl_close($curl_request);
396
+		$response_obj =  new EE_AuthorizeNetAIM_Response($response);
397
+
398
+		return $this->_log_and_clean_response($response_obj, $payment);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Logs the clean data only
404
+	 *
405
+	 * @param array $request_array
406
+	 * @param EEI_Payment $payment
407
+	 */
408
+	protected function _log_clean_request($request_array, $payment)
409
+	{
410
+		$keys_to_filter_out = array('x_card_num', 'x_card_code', 'x_exp_date');
411
+		foreach ($request_array as $index => $keyvaltogether) {
412
+			foreach ($keys_to_filter_out as $key) {
413
+				if (strpos($keyvaltogether, $key) === 0) {
414
+					// found it at the first character
415
+					// so its one of them
416
+					unset($request_array[ $index ]);
417
+				}
418
+			}
419
+		}
420
+		$this->log(
421
+			array(
422
+				'AIM Request sent:' => $request_array,
423
+				'Server URL'        => $this->_get_server_url()
424
+			),
425
+			$payment
426
+		);
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * Logs the response and cleans it
433
+	 *
434
+	 * @param EE_AuthorizeNetAIM_Response $response_obj
435
+	 * @param EE_Payment                  $payment
436
+	 * @return \EE_AuthorizeNetAIM_Response
437
+	 */
438
+	private function _log_and_clean_response($response_obj, $payment)
439
+	{
440
+		$response_obj->account_number = '';
441
+		$this->log(array('AIM Response received:' => (array) $response_obj), $payment);
442
+		return $response_obj;
443
+	}
444 444
 }
445 445
 
446 446
 
@@ -456,192 +456,192 @@  discard block
 block discarded – undo
456 456
 class EE_AuthorizeNetAIM_Response
457 457
 {
458 458
 
459
-    const APPROVED = '1';
460
-    const DECLINED = '2';
461
-    const ERROR = '3';
462
-    const HELD = '4';
463
-
464
-    protected $_x_post_fields = array(
465
-        "version"        => "3.1",
466
-        "delim_char"     => ",",
467
-        "delim_data"     => "TRUE",
468
-        "relay_response" => "FALSE",
469
-        "encap_char"     => "|",
470
-    );
471
-    public $approved;
472
-    public $declined;
473
-    public $error;
474
-    public $held;
475
-    public $response_code;
476
-    public $response_subcode;
477
-    public $response_reason_code;
478
-    public $response_reason_text;
479
-    public $authorization_code;
480
-    public $avs_response;
481
-    public $transaction_id;
482
-    public $invoice_number;
483
-    public $description;
484
-    public $amount;
485
-    public $method;
486
-    public $transaction_type;
487
-    public $customer_id;
488
-    public $first_name;
489
-    public $last_name;
490
-    public $company;
491
-    public $address;
492
-    public $city;
493
-    public $state;
494
-    public $zip_code;
495
-    public $country;
496
-    public $phone;
497
-    public $fax;
498
-    public $email_address;
499
-    public $ship_to_first_name;
500
-    public $ship_to_last_name;
501
-    public $ship_to_company;
502
-    public $ship_to_address;
503
-    public $ship_to_city;
504
-    public $ship_to_state;
505
-    public $ship_to_zip_code;
506
-    public $ship_to_country;
507
-    public $tax;
508
-    public $duty;
509
-    public $freight;
510
-    public $tax_exempt;
511
-    public $purchase_order_number;
512
-    public $md5_hash;
513
-    public $card_code_response;
514
-    public $cavv_response; // cardholder_authentication_verification_response
515
-    public $account_number;
516
-    public $card_type;
517
-    public $split_tender_id;
518
-    public $requested_amount;
519
-    public $balance_on_card;
520
-    public $response; // The response string from AuthorizeNet.
521
-    public $error_message;
522
-    private $_response_array = array(); // An array with the split response.
523
-
524
-
525
-    /**
526
-     * Constructor. Parses the AuthorizeNet response string
527
-     *
528
-     * @param string $response The response from the AuthNet server.
529
-     * @var string   $delimiter The delimiter used (default is ",")
530
-     * @var string   $encap_char The encap_char used (default is "|")
531
-     * @var array    $custom_fields Any custom fields set in the request.
532
-     */
533
-
534
-    public function __construct($response)
535
-    {
536
-        $encap_char = $this->_x_post_fields['encap_char'];
537
-        $delimiter = $this->_x_post_fields['delim_char'];
538
-        if ($response) {
539
-            // Split Array
540
-            $this->response = $response;
541
-            if ($encap_char) {
542
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
543
-            } else {
544
-                $this->_response_array = explode($delimiter, $response);
545
-            }
546
-
547
-            /**
548
-             * If AuthorizeNet doesn't return a delimited response.
549
-             */
550
-            if (count($this->_response_array) < 10) {
551
-                $this->approved = false;
552
-                $this->error = true;
553
-                $this->error_message = sprintf(
554
-                    esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
555
-                    esc_html($response)
556
-                );
557
-                return;
558
-            }
559
-
560
-
561
-
562
-            // Set all fields
563
-            $this->response_code = $this->_response_array[0];
564
-            $this->response_subcode = $this->_response_array[1];
565
-            $this->response_reason_code = $this->_response_array[2];
566
-            $this->response_reason_text = $this->_response_array[3];
567
-            $this->authorization_code = $this->_response_array[4];
568
-            $this->avs_response = $this->_response_array[5];
569
-            $this->transaction_id = $this->_response_array[6];
570
-            $this->invoice_number = $this->_response_array[7];
571
-            $this->description = $this->_response_array[8];
572
-            $this->amount = $this->_response_array[9];
573
-            $this->method = $this->_response_array[10];
574
-            $this->transaction_type = $this->_response_array[11];
575
-            $this->customer_id = $this->_response_array[12];
576
-            $this->first_name = $this->_response_array[13];
577
-            $this->last_name = $this->_response_array[14];
578
-            $this->company = $this->_response_array[15];
579
-            $this->address = $this->_response_array[16];
580
-            $this->city = $this->_response_array[17];
581
-            $this->state = $this->_response_array[18];
582
-            $this->zip_code = $this->_response_array[19];
583
-            $this->country = $this->_response_array[20];
584
-            $this->phone = $this->_response_array[21];
585
-            $this->fax = $this->_response_array[22];
586
-            $this->email_address = $this->_response_array[23];
587
-            $this->ship_to_first_name = $this->_response_array[24];
588
-            $this->ship_to_last_name = $this->_response_array[25];
589
-            $this->ship_to_company = $this->_response_array[26];
590
-            $this->ship_to_address = $this->_response_array[27];
591
-            $this->ship_to_city = $this->_response_array[28];
592
-            $this->ship_to_state = $this->_response_array[29];
593
-            $this->ship_to_zip_code = $this->_response_array[30];
594
-            $this->ship_to_country = $this->_response_array[31];
595
-            $this->tax = $this->_response_array[32];
596
-            $this->duty = $this->_response_array[33];
597
-            $this->freight = $this->_response_array[34];
598
-            $this->tax_exempt = $this->_response_array[35];
599
-            $this->purchase_order_number = $this->_response_array[36];
600
-            $this->md5_hash = $this->_response_array[37];
601
-            $this->card_code_response = $this->_response_array[38];
602
-            $this->cavv_response = $this->_response_array[39];
603
-            $this->account_number = $this->_response_array[50];
604
-            $this->card_type = $this->_response_array[51];
605
-            $this->split_tender_id = $this->_response_array[52];
606
-            $this->requested_amount = $this->_response_array[53];
607
-            $this->balance_on_card = $this->_response_array[54];
608
-
609
-            $this->approved = ($this->response_code === self::APPROVED);
610
-            $this->declined = ($this->response_code === self::DECLINED);
611
-            $this->error = ($this->response_code === self::ERROR);
612
-            $this->held = ($this->response_code === self::HELD);
613
-        } else {
614
-            $this->approved = false;
615
-            $this->error = true;
616
-            $this->error_message = esc_html__(
617
-                'Error connecting to Authorize.net',
618
-                'event_espresso'
619
-            );
620
-        }
621
-    }
459
+	const APPROVED = '1';
460
+	const DECLINED = '2';
461
+	const ERROR = '3';
462
+	const HELD = '4';
463
+
464
+	protected $_x_post_fields = array(
465
+		"version"        => "3.1",
466
+		"delim_char"     => ",",
467
+		"delim_data"     => "TRUE",
468
+		"relay_response" => "FALSE",
469
+		"encap_char"     => "|",
470
+	);
471
+	public $approved;
472
+	public $declined;
473
+	public $error;
474
+	public $held;
475
+	public $response_code;
476
+	public $response_subcode;
477
+	public $response_reason_code;
478
+	public $response_reason_text;
479
+	public $authorization_code;
480
+	public $avs_response;
481
+	public $transaction_id;
482
+	public $invoice_number;
483
+	public $description;
484
+	public $amount;
485
+	public $method;
486
+	public $transaction_type;
487
+	public $customer_id;
488
+	public $first_name;
489
+	public $last_name;
490
+	public $company;
491
+	public $address;
492
+	public $city;
493
+	public $state;
494
+	public $zip_code;
495
+	public $country;
496
+	public $phone;
497
+	public $fax;
498
+	public $email_address;
499
+	public $ship_to_first_name;
500
+	public $ship_to_last_name;
501
+	public $ship_to_company;
502
+	public $ship_to_address;
503
+	public $ship_to_city;
504
+	public $ship_to_state;
505
+	public $ship_to_zip_code;
506
+	public $ship_to_country;
507
+	public $tax;
508
+	public $duty;
509
+	public $freight;
510
+	public $tax_exempt;
511
+	public $purchase_order_number;
512
+	public $md5_hash;
513
+	public $card_code_response;
514
+	public $cavv_response; // cardholder_authentication_verification_response
515
+	public $account_number;
516
+	public $card_type;
517
+	public $split_tender_id;
518
+	public $requested_amount;
519
+	public $balance_on_card;
520
+	public $response; // The response string from AuthorizeNet.
521
+	public $error_message;
522
+	private $_response_array = array(); // An array with the split response.
523
+
524
+
525
+	/**
526
+	 * Constructor. Parses the AuthorizeNet response string
527
+	 *
528
+	 * @param string $response The response from the AuthNet server.
529
+	 * @var string   $delimiter The delimiter used (default is ",")
530
+	 * @var string   $encap_char The encap_char used (default is "|")
531
+	 * @var array    $custom_fields Any custom fields set in the request.
532
+	 */
533
+
534
+	public function __construct($response)
535
+	{
536
+		$encap_char = $this->_x_post_fields['encap_char'];
537
+		$delimiter = $this->_x_post_fields['delim_char'];
538
+		if ($response) {
539
+			// Split Array
540
+			$this->response = $response;
541
+			if ($encap_char) {
542
+				$this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
543
+			} else {
544
+				$this->_response_array = explode($delimiter, $response);
545
+			}
546
+
547
+			/**
548
+			 * If AuthorizeNet doesn't return a delimited response.
549
+			 */
550
+			if (count($this->_response_array) < 10) {
551
+				$this->approved = false;
552
+				$this->error = true;
553
+				$this->error_message = sprintf(
554
+					esc_html__('Unrecognized response from Authorize.net: %1$s', 'event_espresso'),
555
+					esc_html($response)
556
+				);
557
+				return;
558
+			}
559
+
560
+
561
+
562
+			// Set all fields
563
+			$this->response_code = $this->_response_array[0];
564
+			$this->response_subcode = $this->_response_array[1];
565
+			$this->response_reason_code = $this->_response_array[2];
566
+			$this->response_reason_text = $this->_response_array[3];
567
+			$this->authorization_code = $this->_response_array[4];
568
+			$this->avs_response = $this->_response_array[5];
569
+			$this->transaction_id = $this->_response_array[6];
570
+			$this->invoice_number = $this->_response_array[7];
571
+			$this->description = $this->_response_array[8];
572
+			$this->amount = $this->_response_array[9];
573
+			$this->method = $this->_response_array[10];
574
+			$this->transaction_type = $this->_response_array[11];
575
+			$this->customer_id = $this->_response_array[12];
576
+			$this->first_name = $this->_response_array[13];
577
+			$this->last_name = $this->_response_array[14];
578
+			$this->company = $this->_response_array[15];
579
+			$this->address = $this->_response_array[16];
580
+			$this->city = $this->_response_array[17];
581
+			$this->state = $this->_response_array[18];
582
+			$this->zip_code = $this->_response_array[19];
583
+			$this->country = $this->_response_array[20];
584
+			$this->phone = $this->_response_array[21];
585
+			$this->fax = $this->_response_array[22];
586
+			$this->email_address = $this->_response_array[23];
587
+			$this->ship_to_first_name = $this->_response_array[24];
588
+			$this->ship_to_last_name = $this->_response_array[25];
589
+			$this->ship_to_company = $this->_response_array[26];
590
+			$this->ship_to_address = $this->_response_array[27];
591
+			$this->ship_to_city = $this->_response_array[28];
592
+			$this->ship_to_state = $this->_response_array[29];
593
+			$this->ship_to_zip_code = $this->_response_array[30];
594
+			$this->ship_to_country = $this->_response_array[31];
595
+			$this->tax = $this->_response_array[32];
596
+			$this->duty = $this->_response_array[33];
597
+			$this->freight = $this->_response_array[34];
598
+			$this->tax_exempt = $this->_response_array[35];
599
+			$this->purchase_order_number = $this->_response_array[36];
600
+			$this->md5_hash = $this->_response_array[37];
601
+			$this->card_code_response = $this->_response_array[38];
602
+			$this->cavv_response = $this->_response_array[39];
603
+			$this->account_number = $this->_response_array[50];
604
+			$this->card_type = $this->_response_array[51];
605
+			$this->split_tender_id = $this->_response_array[52];
606
+			$this->requested_amount = $this->_response_array[53];
607
+			$this->balance_on_card = $this->_response_array[54];
608
+
609
+			$this->approved = ($this->response_code === self::APPROVED);
610
+			$this->declined = ($this->response_code === self::DECLINED);
611
+			$this->error = ($this->response_code === self::ERROR);
612
+			$this->held = ($this->response_code === self::HELD);
613
+		} else {
614
+			$this->approved = false;
615
+			$this->error = true;
616
+			$this->error_message = esc_html__(
617
+				'Error connecting to Authorize.net',
618
+				'event_espresso'
619
+			);
620
+		}
621
+	}
622 622
 }
623 623
 
624 624
 if (! class_exists('AuthorizeNetException')) {
625
-    /**
626
-     * Class AuthorizeNetException
627
-     *
628
-     * @package    AuthorizeNet
629
-     */
630
-    class AuthorizeNetException extends Exception
631
-    {
632
-
633
-        /**
634
-         * Construct the exception. Note: The message is NOT binary safe.
635
-         *
636
-         * @link http://php.net/manual/en/exception.construct.php
637
-         * @param string $message [optional] The Exception message to throw.
638
-         * @param int $code [optional] The Exception code.
639
-         * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
640
-         * @since 5.1.0
641
-         */
642
-        public function __construct($message = "", $code = 0, Exception $previous = null)
643
-        {
644
-            parent::__construct($message, $code, $previous);
645
-        }
646
-    }
625
+	/**
626
+	 * Class AuthorizeNetException
627
+	 *
628
+	 * @package    AuthorizeNet
629
+	 */
630
+	class AuthorizeNetException extends Exception
631
+	{
632
+
633
+		/**
634
+		 * Construct the exception. Note: The message is NOT binary safe.
635
+		 *
636
+		 * @link http://php.net/manual/en/exception.construct.php
637
+		 * @param string $message [optional] The Exception message to throw.
638
+		 * @param int $code [optional] The Exception code.
639
+		 * @param Exception $previous [optional] The previous exception used for the exception chaining. Since 5.3.0
640
+		 * @since 5.1.0
641
+		 */
642
+		public function __construct($message = "", $code = 0, Exception $previous = null)
643
+		{
644
+			parent::__construct($message, $code, $previous);
645
+		}
646
+	}
647 647
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         // invoice_num would be nice to have it be unique per SPCO page-load, that way if users
249 249
         // press back, they don't submit a duplicate. However, we may be keeping the user on teh same spco page
250 250
         // in which case, we need to generate teh invoice num per request right here...
251
-        $this->setField('invoice_num', wp_generate_password(12, false));// $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
251
+        $this->setField('invoice_num', wp_generate_password(12, false)); // $billing_info['_reg-page-billing-invoice-'.$this->_gateway_name]['value']);
252 252
         // tell AIM that any duplicates sent in the next 5 minutes are to be ignored
253 253
         $this->setField('duplicate_window', 5 * MINUTE_IN_SECONDS);
254 254
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         // Capture response
260 260
         $this->type = "AUTH_CAPTURE";
261 261
         $response = $this->_sendRequest($payment);
262
-        if (! empty($response)) {
262
+        if ( ! empty($response)) {
263 263
             if ($response->error_message) {
264 264
                 $payment->set_status($this->_pay_model->failed_status());
265 265
                 $payment->set_gateway_response($response->error_message);
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
     protected function _set_sensitive_billing_data($billing_info)
306 306
     {
307 307
         $this->setField('card_num', $billing_info['credit_card']);
308
-        $this->setField('exp_date', $billing_info['exp_month'] . $billing_info['exp_year']);
308
+        $this->setField('exp_date', $billing_info['exp_month'].$billing_info['exp_year']);
309 309
         $this->setField('card_code', $billing_info['cvv']);
310 310
     }
311 311
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     protected function setField($name, $value)
346 346
     {
347 347
         if (in_array($name, $this->_all_aim_fields)) {
348
-            $this->_x_post_fields[ $name ] = $value;
348
+            $this->_x_post_fields[$name] = $value;
349 349
         } else {
350 350
             throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
351 351
             To set a custom field use setCustomField('field','value') instead.");
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
         $this->_x_post_fields['tran_key'] = $this->_transaction_key;
366 366
         $x_keys = array();
367 367
         foreach ($this->_x_post_fields as $key => $value) {
368
-            $x_keys[] = "x_$key=" . urlencode($this->_get_unsupported_character_remover()->format($value));
368
+            $x_keys[] = "x_$key=".urlencode($this->_get_unsupported_character_remover()->format($value));
369 369
         }
370 370
         // Add line items
371 371
         foreach ($this->_additional_line_items as $key => $value) {
372
-            $x_keys[] =  "x_line_item=" . urlencode($this->_get_unsupported_character_remover()->format($value));
372
+            $x_keys[] = "x_line_item=".urlencode($this->_get_unsupported_character_remover()->format($value));
373 373
         }
374 374
         $this->_log_clean_request($x_keys, $payment);
375 375
         $post_url = $this->_get_server_url();
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
382 382
         curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
383 383
         if ($this->VERIFY_PEER) {
384
-            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__) . '/ssl/cert.pem');
384
+            curl_setopt($curl_request, CURLOPT_CAINFO, dirname(__DIR__).'/ssl/cert.pem');
385 385
         } else {
386 386
             curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
387 387
         }
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
         $response = curl_exec($curl_request);
394 394
 
395 395
         curl_close($curl_request);
396
-        $response_obj =  new EE_AuthorizeNetAIM_Response($response);
396
+        $response_obj = new EE_AuthorizeNetAIM_Response($response);
397 397
 
398 398
         return $this->_log_and_clean_response($response_obj, $payment);
399 399
     }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                 if (strpos($keyvaltogether, $key) === 0) {
414 414
                     // found it at the first character
415 415
                     // so its one of them
416
-                    unset($request_array[ $index ]);
416
+                    unset($request_array[$index]);
417 417
                 }
418 418
             }
419 419
         }
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
             // Split Array
540 540
             $this->response = $response;
541 541
             if ($encap_char) {
542
-                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
542
+                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
543 543
             } else {
544 544
                 $this->_response_array = explode($delimiter, $response);
545 545
             }
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
     }
622 622
 }
623 623
 
624
-if (! class_exists('AuthorizeNetException')) {
624
+if ( ! class_exists('AuthorizeNetException')) {
625 625
     /**
626 626
      * Class AuthorizeNetException
627 627
      *
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 2 patches
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -1,12 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use EventEspresso\core\domain\DomainFactory;
4
-use EventEspresso\core\domain\values\FilePath;
5
-use EventEspresso\core\domain\values\FullyQualifiedName;
6
-use EventEspresso\core\domain\values\Version;
7 3
 use EventEspresso\core\exceptions\InvalidDataTypeException;
8 4
 use EventEspresso\core\exceptions\InvalidInterfaceException;
9
-use EventEspresso\core\services\loaders\LoaderFactory;
10 5
 use EventEspresso\core\services\request\RequestDecoratorInterface;
11 6
 use EventEspresso\core\services\request\RequestInterface;
12 7
 use EventEspresso\core\services\request\RequestStackCoreAppInterface;
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -27,114 +27,114 @@
 block discarded – undo
27 27
 class EE_Load_Espresso_Core implements RequestDecoratorInterface, RequestStackCoreAppInterface
28 28
 {
29 29
 
30
-    /**
31
-     * @var RequestInterface $request
32
-     */
33
-    protected $request;
34
-
35
-    /**
36
-     * @var ResponseInterface $response
37
-     */
38
-    protected $response;
39
-
40
-    /**
41
-     * @var EE_Dependency_Map $dependency_map
42
-     */
43
-    protected $dependency_map;
44
-
45
-    /**
46
-     * @var EE_Registry $registry
47
-     */
48
-    protected $registry;
49
-
50
-
51
-    /**
52
-     * EE_Load_Espresso_Core constructor
53
-     *
54
-     * @param EE_Registry       $registry
55
-     * @param EE_Dependency_Map $dependency_map
56
-     * @throws EE_Error
57
-     */
58
-    public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map)
59
-    {
60
-        EE_Error::doing_it_wrong(
61
-            __METHOD__,
62
-            sprintf(
63
-                esc_html__(
64
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
65
-                    'event_espresso'
66
-                ),
67
-                'EventEspresso\core\services\request\RequestStackCoreApp',
68
-                '\core\services\request',
69
-                'EventEspresso\core\services\request'
70
-            ),
71
-            '4.9.53'
72
-        );
73
-    }
74
-
75
-
76
-    /**
77
-     * handle
78
-     * sets hooks for running rest of system
79
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
80
-     * starting EE Addons from any other point may lead to problems
81
-     *
82
-     * @param RequestInterface  $request
83
-     * @param ResponseInterface $response
84
-     * @return ResponseInterface
85
-     * @throws EE_Error
86
-     * @throws InvalidDataTypeException
87
-     * @throws InvalidInterfaceException
88
-     * @throws InvalidArgumentException
89
-     * @throws DomainException
90
-     */
91
-    public function handleRequest(RequestInterface $request, ResponseInterface $response)
92
-    {
93
-    }
94
-
95
-
96
-    /**
97
-     * @return RequestInterface
98
-     */
99
-    public function request()
100
-    {
101
-    }
102
-
103
-
104
-    /**
105
-     * @return ResponseInterface
106
-     */
107
-    public function response()
108
-    {
109
-    }
110
-
111
-
112
-    /**
113
-     * @return EE_Dependency_Map
114
-     * @throws EE_Error
115
-     */
116
-    public function dependency_map()
117
-    {
118
-    }
119
-
120
-
121
-    /**
122
-     * @return EE_Registry
123
-     * @throws EE_Error
124
-     */
125
-    public function registry()
126
-    {
127
-    }
128
-
129
-
130
-    /**
131
-     * called after the request stack has been fully processed
132
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
133
-     *
134
-     * @param RequestInterface  $request
135
-     * @param ResponseInterface $response
136
-     */
137
-    public function handleResponse(RequestInterface $request, ResponseInterface $response)
138
-    {
139
-    }
30
+	/**
31
+	 * @var RequestInterface $request
32
+	 */
33
+	protected $request;
34
+
35
+	/**
36
+	 * @var ResponseInterface $response
37
+	 */
38
+	protected $response;
39
+
40
+	/**
41
+	 * @var EE_Dependency_Map $dependency_map
42
+	 */
43
+	protected $dependency_map;
44
+
45
+	/**
46
+	 * @var EE_Registry $registry
47
+	 */
48
+	protected $registry;
49
+
50
+
51
+	/**
52
+	 * EE_Load_Espresso_Core constructor
53
+	 *
54
+	 * @param EE_Registry       $registry
55
+	 * @param EE_Dependency_Map $dependency_map
56
+	 * @throws EE_Error
57
+	 */
58
+	public function __construct(EE_Registry $registry, EE_Dependency_Map $dependency_map)
59
+	{
60
+		EE_Error::doing_it_wrong(
61
+			__METHOD__,
62
+			sprintf(
63
+				esc_html__(
64
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
65
+					'event_espresso'
66
+				),
67
+				'EventEspresso\core\services\request\RequestStackCoreApp',
68
+				'\core\services\request',
69
+				'EventEspresso\core\services\request'
70
+			),
71
+			'4.9.53'
72
+		);
73
+	}
74
+
75
+
76
+	/**
77
+	 * handle
78
+	 * sets hooks for running rest of system
79
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
80
+	 * starting EE Addons from any other point may lead to problems
81
+	 *
82
+	 * @param RequestInterface  $request
83
+	 * @param ResponseInterface $response
84
+	 * @return ResponseInterface
85
+	 * @throws EE_Error
86
+	 * @throws InvalidDataTypeException
87
+	 * @throws InvalidInterfaceException
88
+	 * @throws InvalidArgumentException
89
+	 * @throws DomainException
90
+	 */
91
+	public function handleRequest(RequestInterface $request, ResponseInterface $response)
92
+	{
93
+	}
94
+
95
+
96
+	/**
97
+	 * @return RequestInterface
98
+	 */
99
+	public function request()
100
+	{
101
+	}
102
+
103
+
104
+	/**
105
+	 * @return ResponseInterface
106
+	 */
107
+	public function response()
108
+	{
109
+	}
110
+
111
+
112
+	/**
113
+	 * @return EE_Dependency_Map
114
+	 * @throws EE_Error
115
+	 */
116
+	public function dependency_map()
117
+	{
118
+	}
119
+
120
+
121
+	/**
122
+	 * @return EE_Registry
123
+	 * @throws EE_Error
124
+	 */
125
+	public function registry()
126
+	{
127
+	}
128
+
129
+
130
+	/**
131
+	 * called after the request stack has been fully processed
132
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
133
+	 *
134
+	 * @param RequestInterface  $request
135
+	 * @param ResponseInterface $response
136
+	 */
137
+	public function handleResponse(RequestInterface $request, ResponseInterface $response)
138
+	{
139
+	}
140 140
 }
Please login to merge, or discard this patch.