Completed
Pull Request — master (#999)
by
unknown
09:18
created
core/services/request/RequestInterface.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -16,145 +16,145 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
-
24
-    /**
25
-     * @return array
26
-     */
27
-    public function getParams();
28
-
29
-
30
-    /**
31
-     * @return array
32
-     */
33
-    public function postParams();
34
-
35
-
36
-    /**
37
-     * @return array
38
-     */
39
-    public function cookieParams();
40
-
41
-
42
-    /**
43
-     * @return array
44
-     */
45
-    public function serverParams();
46
-
47
-
48
-    /**
49
-     * @return array
50
-     */
51
-    public function filesParams();
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23
+
24
+	/**
25
+	 * @return array
26
+	 */
27
+	public function getParams();
28
+
29
+
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function postParams();
34
+
35
+
36
+	/**
37
+	 * @return array
38
+	 */
39
+	public function cookieParams();
40
+
41
+
42
+	/**
43
+	 * @return array
44
+	 */
45
+	public function serverParams();
46
+
47
+
48
+	/**
49
+	 * @return array
50
+	 */
51
+	public function filesParams();
52 52
 
53 53
 
54
-    /**
55
-     * returns contents of $_REQUEST
56
-     *
57
-     * @return array
58
-     */
59
-    public function requestParams();
54
+	/**
55
+	 * returns contents of $_REQUEST
56
+	 *
57
+	 * @return array
58
+	 */
59
+	public function requestParams();
60 60
 
61 61
 
62
-    /**
63
-     * @param string $key
64
-     * @param string $value
65
-     * @param bool   $override_ee
66
-     * @return    void
67
-     */
68
-    public function setRequestParam($key, $value, $override_ee = false);
62
+	/**
63
+	 * @param string $key
64
+	 * @param string $value
65
+	 * @param bool   $override_ee
66
+	 * @return    void
67
+	 */
68
+	public function setRequestParam($key, $value, $override_ee = false);
69 69
 
70 70
 
71
-    /**
72
-     * returns the value for a request param if the given key exists
73
-     *
74
-     * @param string $key
75
-     * @param null   $default
76
-     * @return mixed
77
-     */
78
-    public function getRequestParam($key, $default = null);
71
+	/**
72
+	 * returns the value for a request param if the given key exists
73
+	 *
74
+	 * @param string $key
75
+	 * @param null   $default
76
+	 * @return mixed
77
+	 */
78
+	public function getRequestParam($key, $default = null);
79 79
 
80 80
 
81
-    /**
82
-     * check if param exists
83
-     *
84
-     * @param string $key
85
-     * @return bool
86
-     */
87
-    public function requestParamIsSet($key);
81
+	/**
82
+	 * check if param exists
83
+	 *
84
+	 * @param string $key
85
+	 * @return bool
86
+	 */
87
+	public function requestParamIsSet($key);
88 88
 
89 89
 
90
-    /**
91
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
-     * and return the value for the first match found
93
-     * wildcards can be either of the following:
94
-     *      ? to represent a single character of any type
95
-     *      * to represent one or more characters of any type
96
-     *
97
-     * @param string     $pattern
98
-     * @param null|mixed $default
99
-     * @return false|int
100
-     */
101
-    public function getMatch($pattern, $default = null);
90
+	/**
91
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
92
+	 * and return the value for the first match found
93
+	 * wildcards can be either of the following:
94
+	 *      ? to represent a single character of any type
95
+	 *      * to represent one or more characters of any type
96
+	 *
97
+	 * @param string     $pattern
98
+	 * @param null|mixed $default
99
+	 * @return false|int
100
+	 */
101
+	public function getMatch($pattern, $default = null);
102 102
 
103 103
 
104
-    /**
105
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
106
-     * wildcards can be either of the following:
107
-     *      ? to represent a single character of any type
108
-     *      * to represent one or more characters of any type
109
-     * returns true if a match is found or false if not
110
-     *
111
-     * @param string $pattern
112
-     * @return false|int
113
-     */
114
-    public function matches($pattern);
104
+	/**
105
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
106
+	 * wildcards can be either of the following:
107
+	 *      ? to represent a single character of any type
108
+	 *      * to represent one or more characters of any type
109
+	 * returns true if a match is found or false if not
110
+	 *
111
+	 * @param string $pattern
112
+	 * @return false|int
113
+	 */
114
+	public function matches($pattern);
115 115
 
116 116
 
117
-    /**
118
-     * remove param
119
-     *
120
-     * @param string $key
121
-     * @param bool   $unset_from_global_too
122
-     */
123
-    public function unSetRequestParam($key, $unset_from_global_too = false);
117
+	/**
118
+	 * remove param
119
+	 *
120
+	 * @param string $key
121
+	 * @param bool   $unset_from_global_too
122
+	 */
123
+	public function unSetRequestParam($key, $unset_from_global_too = false);
124 124
 
125 125
 
126
-    /**
127
-     * @return string
128
-     */
129
-    public function ipAddress();
126
+	/**
127
+	 * @return string
128
+	 */
129
+	public function ipAddress();
130 130
 
131 131
 
132
-    /**
133
-     * @return string
134
-     */
135
-    public function requestUri();
136
-
132
+	/**
133
+	 * @return string
134
+	 */
135
+	public function requestUri();
136
+
137 137
 
138
-    /**
139
-     * @return string
140
-     */
141
-    public function userAgent();
142
-
143
-
144
-    /**
145
-     * @param string $user_agent
146
-     */
147
-    public function setUserAgent($user_agent = '');
148
-
149
-
150
-    /**
151
-     * @return bool
152
-     */
153
-    public function isBot();
154
-
155
-
156
-    /**
157
-     * @param bool $is_bot
158
-     */
159
-    public function setIsBot($is_bot);
138
+	/**
139
+	 * @return string
140
+	 */
141
+	public function userAgent();
142
+
143
+
144
+	/**
145
+	 * @param string $user_agent
146
+	 */
147
+	public function setUserAgent($user_agent = '');
148
+
149
+
150
+	/**
151
+	 * @return bool
152
+	 */
153
+	public function isBot();
154
+
155
+
156
+	/**
157
+	 * @param bool $is_bot
158
+	 */
159
+	public function setIsBot($is_bot);
160 160
 }
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +620 added lines, -620 removed lines patch added patch discarded remove patch
@@ -17,624 +17,624 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_GET parameters
22
-     *
23
-     * @var array $get
24
-     */
25
-    private $get;
26
-
27
-    /**
28
-     * $_POST parameters
29
-     *
30
-     * @var array $post
31
-     */
32
-    private $post;
33
-
34
-    /**
35
-     * $_COOKIE parameters
36
-     *
37
-     * @var array $cookie
38
-     */
39
-    private $cookie;
40
-
41
-    /**
42
-     * $_SERVER parameters
43
-     *
44
-     * @var array $server
45
-     */
46
-    private $server;
47
-
48
-    /**
49
-     * $_FILES parameters
50
-     *
51
-     * @var array $files
52
-     */
53
-    private $files;
54
-
55
-    /**
56
-     * $_REQUEST parameters
57
-     *
58
-     * @var array $request
59
-     */
60
-    private $request;
61
-
62
-    /**
63
-     * @var RequestTypeContextCheckerInterface
64
-     */
65
-    private $request_type;
66
-
67
-    /**
68
-     * IP address for request
69
-     *
70
-     * @var string $ip_address
71
-     */
72
-    private $ip_address;
73
-
74
-    /**
75
-     * @var string $user_agent
76
-     */
77
-    private $user_agent;
78
-
79
-    /**
80
-     * true if current user appears to be some kind of bot
81
-     *
82
-     * @var bool $is_bot
83
-     */
84
-    private $is_bot;
85
-
86
-
87
-    /**
88
-     * @param array $get
89
-     * @param array $post
90
-     * @param array $cookie
91
-     * @param array $server
92
-     * @param array $files
93
-     */
94
-    public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
-    {
96
-        // grab request vars
97
-        $this->get = $get;
98
-        $this->post = $post;
99
-        $this->cookie = $cookie;
100
-        $this->server = $server;
101
-        $this->files = $files;
102
-        $this->request = array_merge($this->get, $this->post);
103
-        $this->ip_address = $this->visitorIp();
104
-    }
105
-
106
-
107
-    /**
108
-     * @param RequestTypeContextCheckerInterface $type
109
-     */
110
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
-    {
112
-        $this->request_type = $type;
113
-    }
114
-
115
-
116
-    /**
117
-     * @return array
118
-     */
119
-    public function getParams()
120
-    {
121
-        return $this->get;
122
-    }
123
-
124
-
125
-    /**
126
-     * @return array
127
-     */
128
-    public function postParams()
129
-    {
130
-        return $this->post;
131
-    }
132
-
133
-
134
-    /**
135
-     * @return array
136
-     */
137
-    public function cookieParams()
138
-    {
139
-        return $this->cookie;
140
-    }
141
-
142
-
143
-    /**
144
-     * @return array
145
-     */
146
-    public function serverParams()
147
-    {
148
-        return $this->server;
149
-    }
150
-
151
-
152
-    /**
153
-     * @return array
154
-     */
155
-    public function filesParams()
156
-    {
157
-        return $this->files;
158
-    }
159
-
160
-
161
-    /**
162
-     * returns contents of $_REQUEST
163
-     *
164
-     * @return array
165
-     */
166
-    public function requestParams()
167
-    {
168
-        return $this->request;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param      $key
174
-     * @param      $value
175
-     * @param bool $override_ee
176
-     * @return    void
177
-     */
178
-    public function setRequestParam($key, $value, $override_ee = false)
179
-    {
180
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
181
-        if ($key !== 'ee'
182
-            || ($key === 'ee' && empty($this->request['ee']))
183
-            || ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
-        ) {
185
-            $this->request[ $key ] = $value;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     * returns   the value for a request param if the given key exists
192
-     *
193
-     * @param       $key
194
-     * @param null  $default
195
-     * @return mixed
196
-     */
197
-    public function getRequestParam($key, $default = null)
198
-    {
199
-        return $this->requestParameterDrillDown($key, $default, 'get');
200
-    }
201
-
202
-
203
-    /**
204
-     * check if param exists
205
-     *
206
-     * @param       $key
207
-     * @return bool
208
-     */
209
-    public function requestParamIsSet($key)
210
-    {
211
-        return $this->requestParameterDrillDown($key);
212
-    }
213
-
214
-
215
-    /**
216
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
-     * and return the value for the first match found
218
-     * wildcards can be either of the following:
219
-     *      ? to represent a single character of any type
220
-     *      * to represent one or more characters of any type
221
-     *
222
-     * @param string     $pattern
223
-     * @param null|mixed $default
224
-     * @return mixed
225
-     */
226
-    public function getMatch($pattern, $default = null)
227
-    {
228
-        return $this->requestParameterDrillDown($pattern, $default, 'match');
229
-    }
230
-
231
-
232
-    /**
233
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
234
-     * wildcards can be either of the following:
235
-     *      ? to represent a single character of any type
236
-     *      * to represent one or more characters of any type
237
-     * returns true if a match is found or false if not
238
-     *
239
-     * @param string $pattern
240
-     * @return bool
241
-     */
242
-    public function matches($pattern)
243
-    {
244
-        return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
-    }
246
-
247
-
248
-    /**
249
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
-     *                                      and used to search through the current request's parameter keys
252
-     * @param array  $request_params        The array of request parameters to search through
253
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
254
-     *                                      Default is null
255
-     * @param string $return                [optional] Controls what kind of value is returned.
256
-     *                                      Options are:
257
-     *                                      'bool' will return true or false if match is found or not
258
-     *                                      'key' will return the first key found that matches the supplied pattern
259
-     *                                      'value' will return the value for the first request parameter
260
-     *                                      whose key matches the supplied pattern
261
-     *                                      Default is 'value'
262
-     * @return boolean|string
263
-     */
264
-    private function match($pattern, array $request_params, $default = null, $return = 'value')
265
-    {
266
-        $return = in_array($return, array('bool', 'key', 'value'), true)
267
-            ? $return
268
-            : 'is_set';
269
-        // replace wildcard chars with regex chars
270
-        $pattern = str_replace(
271
-            array("\*", "\?"),
272
-            array('.*', '.'),
273
-            preg_quote($pattern, '/')
274
-        );
275
-        foreach ($request_params as $key => $request_param) {
276
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
277
-                // return value for request param
278
-                if ($return === 'value') {
279
-                    return $request_params[ $key ];
280
-                }
281
-                // or actual key or true just to indicate it was found
282
-                return $return === 'key' ? $key : true;
283
-            }
284
-        }
285
-        // match not found so return default value or false
286
-        return $return === 'value' ? $default : false;
287
-    }
288
-
289
-
290
-    /**
291
-     * the supplied key can be a simple string to represent a "top-level" request parameter
292
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
-     * by using square brackets to surround keys for deeper array elements.
294
-     * For example :
295
-     * if the supplied $key was: "first[second][third]"
296
-     * then this will attempt to drill down into the request parameter array to find a value.
297
-     * Given the following request parameters:
298
-     *  array(
299
-     *      'first' => array(
300
-     *          'second' => array(
301
-     *              'third' => 'has a value'
302
-     *          )
303
-     *      )
304
-     *  )
305
-     * would return true if default parameters were set
306
-     *
307
-     * @param string $callback
308
-     * @param        $key
309
-     * @param null   $default
310
-     * @param array  $request_params
311
-     * @return bool|mixed|null
312
-     */
313
-    private function requestParameterDrillDown(
314
-        $key,
315
-        $default = null,
316
-        $callback = 'is_set',
317
-        array $request_params = array()
318
-    ) {
319
-        $callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
-            ? $callback
321
-            : 'is_set';
322
-        $request_params = ! empty($request_params)
323
-            ? $request_params
324
-            : $this->request;
325
-        // does incoming key represent an array like 'first[second][third]'  ?
326
-        if (strpos($key, '[') !== false) {
327
-            // turn it into an actual array
328
-            $key = str_replace(']', '', $key);
329
-            $keys = explode('[', $key);
330
-            $key = array_shift($keys);
331
-            if ($callback === 'match') {
332
-                $real_key = $this->match($key, $request_params, $default, 'key');
333
-                $key = $real_key ? $real_key : $key;
334
-            }
335
-            // check if top level key exists
336
-            if (isset($request_params[ $key ])) {
337
-                // build a new key to pass along like: 'second[third]'
338
-                // or just 'second' depending on depth of keys
339
-                $key_string = array_shift($keys);
340
-                if (! empty($keys)) {
341
-                    $key_string .= '[' . implode('][', $keys) . ']';
342
-                }
343
-                return $this->requestParameterDrillDown(
344
-                    $key_string,
345
-                    $default,
346
-                    $callback,
347
-                    $request_params[ $key ]
348
-                );
349
-            }
350
-        }
351
-        if ($callback === 'is_set') {
352
-            return isset($request_params[ $key ]);
353
-        }
354
-        if ($callback === 'match') {
355
-            return $this->match($key, $request_params, $default);
356
-        }
357
-        return isset($request_params[ $key ])
358
-            ? $request_params[ $key ]
359
-            : $default;
360
-    }
361
-
362
-
363
-    /**
364
-     * remove param
365
-     *
366
-     * @param      $key
367
-     * @param bool $unset_from_global_too
368
-     */
369
-    public function unSetRequestParam($key, $unset_from_global_too = false)
370
-    {
371
-        unset($this->request[ $key ]);
372
-        if ($unset_from_global_too) {
373
-            unset($_REQUEST[ $key ]);
374
-        }
375
-    }
376
-
377
-
378
-    /**
379
-     * @return string
380
-     */
381
-    public function ipAddress()
382
-    {
383
-        return $this->ip_address;
384
-    }
385
-
386
-
387
-    /**
388
-     * attempt to get IP address of current visitor from server
389
-     * plz see: http://stackoverflow.com/a/2031935/1475279
390
-     *
391
-     * @access public
392
-     * @return string
393
-     */
394
-    private function visitorIp()
395
-    {
396
-        $visitor_ip = '0.0.0.0';
397
-        $server_keys = array(
398
-            'HTTP_CLIENT_IP',
399
-            'HTTP_X_FORWARDED_FOR',
400
-            'HTTP_X_FORWARDED',
401
-            'HTTP_X_CLUSTER_CLIENT_IP',
402
-            'HTTP_FORWARDED_FOR',
403
-            'HTTP_FORWARDED',
404
-            'REMOTE_ADDR',
405
-        );
406
-        foreach ($server_keys as $key) {
407
-            if (isset($this->server[ $key ])) {
408
-                foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
409
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
410
-                        $visitor_ip = $ip;
411
-                    }
412
-                }
413
-            }
414
-        }
415
-        return $visitor_ip;
416
-    }
417
-
418
-
419
-    /**
420
-     * @return string
421
-     */
422
-    public function requestUri()
423
-    {
424
-        $request_uri = filter_input(
425
-            INPUT_SERVER,
426
-            'REQUEST_URI',
427
-            FILTER_SANITIZE_URL,
428
-            FILTER_NULL_ON_FAILURE
429
-        );
430
-        if (empty($request_uri)) {
431
-            // fallback sanitization if the above fails
432
-            $request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
433
-        }
434
-        return $request_uri;
435
-    }
436
-
437
-
438
-    /**
439
-     * @return string
440
-     */
441
-    public function userAgent()
442
-    {
443
-        return $this->user_agent;
444
-    }
445
-
446
-
447
-    /**
448
-     * @param string $user_agent
449
-     */
450
-    public function setUserAgent($user_agent = '')
451
-    {
452
-        if ($user_agent === '' || ! is_string($user_agent)) {
453
-            $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
454
-        }
455
-        $this->user_agent = $user_agent;
456
-    }
457
-
458
-
459
-    /**
460
-     * @return bool
461
-     */
462
-    public function isBot()
463
-    {
464
-        return $this->is_bot;
465
-    }
466
-
467
-
468
-    /**
469
-     * @param bool $is_bot
470
-     */
471
-    public function setIsBot($is_bot)
472
-    {
473
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
474
-    }
475
-
476
-
477
-    /**
478
-     * @return bool
479
-     */
480
-    public function isActivation()
481
-    {
482
-        return $this->request_type->isActivation();
483
-    }
484
-
485
-
486
-    /**
487
-     * @param $is_activation
488
-     * @return bool
489
-     */
490
-    public function setIsActivation($is_activation)
491
-    {
492
-        return $this->request_type->setIsActivation($is_activation);
493
-    }
494
-
495
-
496
-    /**
497
-     * @return bool
498
-     */
499
-    public function isAdmin()
500
-    {
501
-        return $this->request_type->isAdmin();
502
-    }
503
-
504
-
505
-    /**
506
-     * @return bool
507
-     */
508
-    public function isAdminAjax()
509
-    {
510
-        return $this->request_type->isAdminAjax();
511
-    }
512
-
513
-
514
-    /**
515
-     * @return bool
516
-     */
517
-    public function isAjax()
518
-    {
519
-        return $this->request_type->isAjax();
520
-    }
521
-
522
-
523
-    /**
524
-     * @return bool
525
-     */
526
-    public function isEeAjax()
527
-    {
528
-        return $this->request_type->isEeAjax();
529
-    }
530
-
531
-
532
-    /**
533
-     * @return bool
534
-     */
535
-    public function isOtherAjax()
536
-    {
537
-        return $this->request_type->isOtherAjax();
538
-    }
539
-
540
-
541
-    /**
542
-     * @return bool
543
-     */
544
-    public function isApi()
545
-    {
546
-        return $this->request_type->isApi();
547
-    }
548
-
549
-
550
-    /**
551
-     * @return bool
552
-     */
553
-    public function isCli()
554
-    {
555
-        return $this->request_type->isCli();
556
-    }
557
-
558
-
559
-    /**
560
-     * @return bool
561
-     */
562
-    public function isCron()
563
-    {
564
-        return $this->request_type->isCron();
565
-    }
566
-
567
-
568
-    /**
569
-     * @return bool
570
-     */
571
-    public function isFeed()
572
-    {
573
-        return $this->request_type->isFeed();
574
-    }
575
-
576
-
577
-    /**
578
-     * @return bool
579
-     */
580
-    public function isFrontend()
581
-    {
582
-        return $this->request_type->isFrontend();
583
-    }
584
-
585
-
586
-    /**
587
-     * @return bool
588
-     */
589
-    public function isFrontAjax()
590
-    {
591
-        return $this->request_type->isFrontAjax();
592
-    }
593
-
594
-
595
-    /**
596
-     * @return bool
597
-     */
598
-    public function isIframe()
599
-    {
600
-        return $this->request_type->isIframe();
601
-    }
602
-
603
-
604
-    /**
605
-     * @return bool
606
-     */
607
-    public function isWordPressApi()
608
-    {
609
-        return $this->request_type->isWordPressApi();
610
-    }
611
-
612
-
613
-
614
-    /**
615
-     * @return bool
616
-     */
617
-    public function isWordPressHeartbeat()
618
-    {
619
-        return $this->request_type->isWordPressHeartbeat();
620
-    }
621
-
622
-
623
-
624
-    /**
625
-     * @return bool
626
-     */
627
-    public function isWordPressScrape()
628
-    {
629
-        return $this->request_type->isWordPressScrape();
630
-    }
631
-
632
-
633
-    /**
634
-     * @return string
635
-     */
636
-    public function slug()
637
-    {
638
-        return $this->request_type->slug();
639
-    }
20
+	/**
21
+	 * $_GET parameters
22
+	 *
23
+	 * @var array $get
24
+	 */
25
+	private $get;
26
+
27
+	/**
28
+	 * $_POST parameters
29
+	 *
30
+	 * @var array $post
31
+	 */
32
+	private $post;
33
+
34
+	/**
35
+	 * $_COOKIE parameters
36
+	 *
37
+	 * @var array $cookie
38
+	 */
39
+	private $cookie;
40
+
41
+	/**
42
+	 * $_SERVER parameters
43
+	 *
44
+	 * @var array $server
45
+	 */
46
+	private $server;
47
+
48
+	/**
49
+	 * $_FILES parameters
50
+	 *
51
+	 * @var array $files
52
+	 */
53
+	private $files;
54
+
55
+	/**
56
+	 * $_REQUEST parameters
57
+	 *
58
+	 * @var array $request
59
+	 */
60
+	private $request;
61
+
62
+	/**
63
+	 * @var RequestTypeContextCheckerInterface
64
+	 */
65
+	private $request_type;
66
+
67
+	/**
68
+	 * IP address for request
69
+	 *
70
+	 * @var string $ip_address
71
+	 */
72
+	private $ip_address;
73
+
74
+	/**
75
+	 * @var string $user_agent
76
+	 */
77
+	private $user_agent;
78
+
79
+	/**
80
+	 * true if current user appears to be some kind of bot
81
+	 *
82
+	 * @var bool $is_bot
83
+	 */
84
+	private $is_bot;
85
+
86
+
87
+	/**
88
+	 * @param array $get
89
+	 * @param array $post
90
+	 * @param array $cookie
91
+	 * @param array $server
92
+	 * @param array $files
93
+	 */
94
+	public function __construct(array $get, array $post, array $cookie, array $server, array $files = array())
95
+	{
96
+		// grab request vars
97
+		$this->get = $get;
98
+		$this->post = $post;
99
+		$this->cookie = $cookie;
100
+		$this->server = $server;
101
+		$this->files = $files;
102
+		$this->request = array_merge($this->get, $this->post);
103
+		$this->ip_address = $this->visitorIp();
104
+	}
105
+
106
+
107
+	/**
108
+	 * @param RequestTypeContextCheckerInterface $type
109
+	 */
110
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
111
+	{
112
+		$this->request_type = $type;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @return array
118
+	 */
119
+	public function getParams()
120
+	{
121
+		return $this->get;
122
+	}
123
+
124
+
125
+	/**
126
+	 * @return array
127
+	 */
128
+	public function postParams()
129
+	{
130
+		return $this->post;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @return array
136
+	 */
137
+	public function cookieParams()
138
+	{
139
+		return $this->cookie;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @return array
145
+	 */
146
+	public function serverParams()
147
+	{
148
+		return $this->server;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return array
154
+	 */
155
+	public function filesParams()
156
+	{
157
+		return $this->files;
158
+	}
159
+
160
+
161
+	/**
162
+	 * returns contents of $_REQUEST
163
+	 *
164
+	 * @return array
165
+	 */
166
+	public function requestParams()
167
+	{
168
+		return $this->request;
169
+	}
170
+
171
+
172
+	/**
173
+	 * @param      $key
174
+	 * @param      $value
175
+	 * @param bool $override_ee
176
+	 * @return    void
177
+	 */
178
+	public function setRequestParam($key, $value, $override_ee = false)
179
+	{
180
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
181
+		if ($key !== 'ee'
182
+			|| ($key === 'ee' && empty($this->request['ee']))
183
+			|| ($key === 'ee' && ! empty($this->request['ee']) && $override_ee)
184
+		) {
185
+			$this->request[ $key ] = $value;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 * returns   the value for a request param if the given key exists
192
+	 *
193
+	 * @param       $key
194
+	 * @param null  $default
195
+	 * @return mixed
196
+	 */
197
+	public function getRequestParam($key, $default = null)
198
+	{
199
+		return $this->requestParameterDrillDown($key, $default, 'get');
200
+	}
201
+
202
+
203
+	/**
204
+	 * check if param exists
205
+	 *
206
+	 * @param       $key
207
+	 * @return bool
208
+	 */
209
+	public function requestParamIsSet($key)
210
+	{
211
+		return $this->requestParameterDrillDown($key);
212
+	}
213
+
214
+
215
+	/**
216
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
217
+	 * and return the value for the first match found
218
+	 * wildcards can be either of the following:
219
+	 *      ? to represent a single character of any type
220
+	 *      * to represent one or more characters of any type
221
+	 *
222
+	 * @param string     $pattern
223
+	 * @param null|mixed $default
224
+	 * @return mixed
225
+	 */
226
+	public function getMatch($pattern, $default = null)
227
+	{
228
+		return $this->requestParameterDrillDown($pattern, $default, 'match');
229
+	}
230
+
231
+
232
+	/**
233
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
234
+	 * wildcards can be either of the following:
235
+	 *      ? to represent a single character of any type
236
+	 *      * to represent one or more characters of any type
237
+	 * returns true if a match is found or false if not
238
+	 *
239
+	 * @param string $pattern
240
+	 * @return bool
241
+	 */
242
+	public function matches($pattern)
243
+	{
244
+		return $this->requestParameterDrillDown($pattern, null, 'match') !== null;
245
+	}
246
+
247
+
248
+	/**
249
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
250
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
251
+	 *                                      and used to search through the current request's parameter keys
252
+	 * @param array  $request_params        The array of request parameters to search through
253
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
254
+	 *                                      Default is null
255
+	 * @param string $return                [optional] Controls what kind of value is returned.
256
+	 *                                      Options are:
257
+	 *                                      'bool' will return true or false if match is found or not
258
+	 *                                      'key' will return the first key found that matches the supplied pattern
259
+	 *                                      'value' will return the value for the first request parameter
260
+	 *                                      whose key matches the supplied pattern
261
+	 *                                      Default is 'value'
262
+	 * @return boolean|string
263
+	 */
264
+	private function match($pattern, array $request_params, $default = null, $return = 'value')
265
+	{
266
+		$return = in_array($return, array('bool', 'key', 'value'), true)
267
+			? $return
268
+			: 'is_set';
269
+		// replace wildcard chars with regex chars
270
+		$pattern = str_replace(
271
+			array("\*", "\?"),
272
+			array('.*', '.'),
273
+			preg_quote($pattern, '/')
274
+		);
275
+		foreach ($request_params as $key => $request_param) {
276
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
277
+				// return value for request param
278
+				if ($return === 'value') {
279
+					return $request_params[ $key ];
280
+				}
281
+				// or actual key or true just to indicate it was found
282
+				return $return === 'key' ? $key : true;
283
+			}
284
+		}
285
+		// match not found so return default value or false
286
+		return $return === 'value' ? $default : false;
287
+	}
288
+
289
+
290
+	/**
291
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
292
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
293
+	 * by using square brackets to surround keys for deeper array elements.
294
+	 * For example :
295
+	 * if the supplied $key was: "first[second][third]"
296
+	 * then this will attempt to drill down into the request parameter array to find a value.
297
+	 * Given the following request parameters:
298
+	 *  array(
299
+	 *      'first' => array(
300
+	 *          'second' => array(
301
+	 *              'third' => 'has a value'
302
+	 *          )
303
+	 *      )
304
+	 *  )
305
+	 * would return true if default parameters were set
306
+	 *
307
+	 * @param string $callback
308
+	 * @param        $key
309
+	 * @param null   $default
310
+	 * @param array  $request_params
311
+	 * @return bool|mixed|null
312
+	 */
313
+	private function requestParameterDrillDown(
314
+		$key,
315
+		$default = null,
316
+		$callback = 'is_set',
317
+		array $request_params = array()
318
+	) {
319
+		$callback = in_array($callback, array('is_set', 'get', 'match'), true)
320
+			? $callback
321
+			: 'is_set';
322
+		$request_params = ! empty($request_params)
323
+			? $request_params
324
+			: $this->request;
325
+		// does incoming key represent an array like 'first[second][third]'  ?
326
+		if (strpos($key, '[') !== false) {
327
+			// turn it into an actual array
328
+			$key = str_replace(']', '', $key);
329
+			$keys = explode('[', $key);
330
+			$key = array_shift($keys);
331
+			if ($callback === 'match') {
332
+				$real_key = $this->match($key, $request_params, $default, 'key');
333
+				$key = $real_key ? $real_key : $key;
334
+			}
335
+			// check if top level key exists
336
+			if (isset($request_params[ $key ])) {
337
+				// build a new key to pass along like: 'second[third]'
338
+				// or just 'second' depending on depth of keys
339
+				$key_string = array_shift($keys);
340
+				if (! empty($keys)) {
341
+					$key_string .= '[' . implode('][', $keys) . ']';
342
+				}
343
+				return $this->requestParameterDrillDown(
344
+					$key_string,
345
+					$default,
346
+					$callback,
347
+					$request_params[ $key ]
348
+				);
349
+			}
350
+		}
351
+		if ($callback === 'is_set') {
352
+			return isset($request_params[ $key ]);
353
+		}
354
+		if ($callback === 'match') {
355
+			return $this->match($key, $request_params, $default);
356
+		}
357
+		return isset($request_params[ $key ])
358
+			? $request_params[ $key ]
359
+			: $default;
360
+	}
361
+
362
+
363
+	/**
364
+	 * remove param
365
+	 *
366
+	 * @param      $key
367
+	 * @param bool $unset_from_global_too
368
+	 */
369
+	public function unSetRequestParam($key, $unset_from_global_too = false)
370
+	{
371
+		unset($this->request[ $key ]);
372
+		if ($unset_from_global_too) {
373
+			unset($_REQUEST[ $key ]);
374
+		}
375
+	}
376
+
377
+
378
+	/**
379
+	 * @return string
380
+	 */
381
+	public function ipAddress()
382
+	{
383
+		return $this->ip_address;
384
+	}
385
+
386
+
387
+	/**
388
+	 * attempt to get IP address of current visitor from server
389
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
390
+	 *
391
+	 * @access public
392
+	 * @return string
393
+	 */
394
+	private function visitorIp()
395
+	{
396
+		$visitor_ip = '0.0.0.0';
397
+		$server_keys = array(
398
+			'HTTP_CLIENT_IP',
399
+			'HTTP_X_FORWARDED_FOR',
400
+			'HTTP_X_FORWARDED',
401
+			'HTTP_X_CLUSTER_CLIENT_IP',
402
+			'HTTP_FORWARDED_FOR',
403
+			'HTTP_FORWARDED',
404
+			'REMOTE_ADDR',
405
+		);
406
+		foreach ($server_keys as $key) {
407
+			if (isset($this->server[ $key ])) {
408
+				foreach (array_map('trim', explode(',', $this->server[ $key ])) as $ip) {
409
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
410
+						$visitor_ip = $ip;
411
+					}
412
+				}
413
+			}
414
+		}
415
+		return $visitor_ip;
416
+	}
417
+
418
+
419
+	/**
420
+	 * @return string
421
+	 */
422
+	public function requestUri()
423
+	{
424
+		$request_uri = filter_input(
425
+			INPUT_SERVER,
426
+			'REQUEST_URI',
427
+			FILTER_SANITIZE_URL,
428
+			FILTER_NULL_ON_FAILURE
429
+		);
430
+		if (empty($request_uri)) {
431
+			// fallback sanitization if the above fails
432
+			$request_uri = wp_sanitize_redirect($this->server['REQUEST_URI']);
433
+		}
434
+		return $request_uri;
435
+	}
436
+
437
+
438
+	/**
439
+	 * @return string
440
+	 */
441
+	public function userAgent()
442
+	{
443
+		return $this->user_agent;
444
+	}
445
+
446
+
447
+	/**
448
+	 * @param string $user_agent
449
+	 */
450
+	public function setUserAgent($user_agent = '')
451
+	{
452
+		if ($user_agent === '' || ! is_string($user_agent)) {
453
+			$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? (string) esc_attr($_SERVER['HTTP_USER_AGENT']) : '';
454
+		}
455
+		$this->user_agent = $user_agent;
456
+	}
457
+
458
+
459
+	/**
460
+	 * @return bool
461
+	 */
462
+	public function isBot()
463
+	{
464
+		return $this->is_bot;
465
+	}
466
+
467
+
468
+	/**
469
+	 * @param bool $is_bot
470
+	 */
471
+	public function setIsBot($is_bot)
472
+	{
473
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
474
+	}
475
+
476
+
477
+	/**
478
+	 * @return bool
479
+	 */
480
+	public function isActivation()
481
+	{
482
+		return $this->request_type->isActivation();
483
+	}
484
+
485
+
486
+	/**
487
+	 * @param $is_activation
488
+	 * @return bool
489
+	 */
490
+	public function setIsActivation($is_activation)
491
+	{
492
+		return $this->request_type->setIsActivation($is_activation);
493
+	}
494
+
495
+
496
+	/**
497
+	 * @return bool
498
+	 */
499
+	public function isAdmin()
500
+	{
501
+		return $this->request_type->isAdmin();
502
+	}
503
+
504
+
505
+	/**
506
+	 * @return bool
507
+	 */
508
+	public function isAdminAjax()
509
+	{
510
+		return $this->request_type->isAdminAjax();
511
+	}
512
+
513
+
514
+	/**
515
+	 * @return bool
516
+	 */
517
+	public function isAjax()
518
+	{
519
+		return $this->request_type->isAjax();
520
+	}
521
+
522
+
523
+	/**
524
+	 * @return bool
525
+	 */
526
+	public function isEeAjax()
527
+	{
528
+		return $this->request_type->isEeAjax();
529
+	}
530
+
531
+
532
+	/**
533
+	 * @return bool
534
+	 */
535
+	public function isOtherAjax()
536
+	{
537
+		return $this->request_type->isOtherAjax();
538
+	}
539
+
540
+
541
+	/**
542
+	 * @return bool
543
+	 */
544
+	public function isApi()
545
+	{
546
+		return $this->request_type->isApi();
547
+	}
548
+
549
+
550
+	/**
551
+	 * @return bool
552
+	 */
553
+	public function isCli()
554
+	{
555
+		return $this->request_type->isCli();
556
+	}
557
+
558
+
559
+	/**
560
+	 * @return bool
561
+	 */
562
+	public function isCron()
563
+	{
564
+		return $this->request_type->isCron();
565
+	}
566
+
567
+
568
+	/**
569
+	 * @return bool
570
+	 */
571
+	public function isFeed()
572
+	{
573
+		return $this->request_type->isFeed();
574
+	}
575
+
576
+
577
+	/**
578
+	 * @return bool
579
+	 */
580
+	public function isFrontend()
581
+	{
582
+		return $this->request_type->isFrontend();
583
+	}
584
+
585
+
586
+	/**
587
+	 * @return bool
588
+	 */
589
+	public function isFrontAjax()
590
+	{
591
+		return $this->request_type->isFrontAjax();
592
+	}
593
+
594
+
595
+	/**
596
+	 * @return bool
597
+	 */
598
+	public function isIframe()
599
+	{
600
+		return $this->request_type->isIframe();
601
+	}
602
+
603
+
604
+	/**
605
+	 * @return bool
606
+	 */
607
+	public function isWordPressApi()
608
+	{
609
+		return $this->request_type->isWordPressApi();
610
+	}
611
+
612
+
613
+
614
+	/**
615
+	 * @return bool
616
+	 */
617
+	public function isWordPressHeartbeat()
618
+	{
619
+		return $this->request_type->isWordPressHeartbeat();
620
+	}
621
+
622
+
623
+
624
+	/**
625
+	 * @return bool
626
+	 */
627
+	public function isWordPressScrape()
628
+	{
629
+		return $this->request_type->isWordPressScrape();
630
+	}
631
+
632
+
633
+	/**
634
+	 * @return string
635
+	 */
636
+	public function slug()
637
+	{
638
+		return $this->request_type->slug();
639
+	}
640 640
 }
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 1 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, $_FILES);
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, $_FILES);
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/services/request/files/FileSubmission.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function getType()
73 73
     {
74
-        if (!$this->type) {
74
+        if ( ! $this->type) {
75 75
             $this->type = $this->determineType();
76 76
         }
77 77
         return $this->type;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function determineType()
85 85
     {
86
-        if (!$this->getTmpFile()) {
86
+        if ( ! $this->getTmpFile()) {
87 87
             return '';
88 88
         }
89 89
         $finfo = new finfo(FILEINFO_MIME_TYPE);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function getExtension()
99 99
     {
100
-        if (!$this->extension) {
100
+        if ( ! $this->extension) {
101 101
             $this->extension = $this->determineExtension();
102 102
         }
103 103
         return $this->extension;
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     protected function determineExtension()
112 112
     {
113
-        if (!$this->getTmpFile()) {
113
+        if ( ! $this->getTmpFile()) {
114 114
             return '';
115 115
         }
116 116
         return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
Please login to merge, or discard this patch.
Indentation   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -19,158 +19,158 @@
 block discarded – undo
19 19
  */
20 20
 class FileSubmission implements FileSubmissionInterface
21 21
 {
22
-    /**
23
-     * @var string original name on the client machine
24
-     */
25
-    protected $name;
26
-
27
-    /**
28
-     * @var string mime type
29
-     */
30
-    protected $type;
31
-
32
-    /**
33
-     * @var string file extension
34
-     */
35
-    protected $extension;
36
-
37
-    /**
38
-     * @var int in bytes
39
-     */
40
-    protected $size;
41
-
42
-    /**
43
-     * @var string local filepath to the temporary file
44
-     */
45
-    protected $tmp_file;
46
-
47
-    /**
48
-     * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
-     * although those aren't expected.
50
-     */
51
-    protected $error_code;
52
-
53
-    /**
54
-     * FileSubmission constructor.
55
-     * @param $name
56
-     * @param $tmp_file
57
-     * @param $size
58
-     * @param null $error_code
59
-     * @throws InvalidArgumentException
60
-     */
61
-    public function __construct($name, $tmp_file, $size, $error_code = null)
62
-    {
63
-        $this->name = basename($name);
64
-        if (parse_url($tmp_file, PHP_URL_SCHEME)) {
65
-            // Wait a minute- just local filepaths please, no URL schemes allowed!
66
-            throw new InvalidArgumentException(
67
-                sprintf(
68
-                    // @codingStandardsIgnoreStart
69
-                    esc_html__('The filepath of the temporary file ("%1$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
70
-                    // @codingStandardsIgnoreEnd
71
-                    $tmp_file
72
-                )
73
-            );
74
-        }
75
-        $this->tmp_file = (string) $tmp_file;
76
-        $this->size = (int) $size;
77
-        $this->error_code = (int) $error_code;
78
-    }
79
-
80
-    /**
81
-     * @return string
82
-     */
83
-    public function getName()
84
-    {
85
-        return $this->name;
86
-    }
87
-
88
-    /**
89
-     * Gets the file's mime type
90
-     * @return string
91
-     */
92
-    public function getType()
93
-    {
94
-        if (!$this->type) {
95
-            $this->type = $this->determineType();
96
-        }
97
-        return $this->type;
98
-    }
99
-
100
-    /**
101
-     * @since $VID:$
102
-     * @return string
103
-     */
104
-    protected function determineType()
105
-    {
106
-        if (!$this->getTmpFile()) {
107
-            return '';
108
-        }
109
-        $finfo = new finfo(FILEINFO_MIME_TYPE);
110
-        return $finfo->file($this->getTmpFile());
111
-    }
112
-
113
-    /**
114
-     * Gets the file's extension.
115
-     * @since $VID:$
116
-     * @return string
117
-     */
118
-    public function getExtension()
119
-    {
120
-        if (!$this->extension) {
121
-            $this->extension = $this->determineExtension();
122
-        }
123
-        return $this->extension;
124
-    }
125
-
126
-    /**
127
-     * Determine's the file's extension given the temporary file.
128
-     * @since $VID:$
129
-     * @return string
130
-     */
131
-    protected function determineExtension()
132
-    {
133
-        if (!$this->getTmpFile()) {
134
-            return '';
135
-        }
136
-        return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
137
-    }
138
-
139
-    /**
140
-     * Gets the size of the file
141
-     * @return int
142
-     */
143
-    public function getSize()
144
-    {
145
-        return $this->size;
146
-    }
147
-
148
-    /**
149
-     * Gets the path to the temporary file which was uploaded.
150
-     * @return string
151
-     */
152
-    public function getTmpFile()
153
-    {
154
-        return $this->tmp_file;
155
-    }
156
-
157
-    /**
158
-     * @since $VID:$
159
-     * @return string
160
-     */
161
-    public function __toString()
162
-    {
163
-        return $this->getTmpFile();
164
-    }
165
-
166
-    /**
167
-     * Gets the error code PHP reported for the file upload.
168
-     * @return string
169
-     */
170
-    public function getErrorCode()
171
-    {
172
-        return $this->error_code;
173
-    }
22
+	/**
23
+	 * @var string original name on the client machine
24
+	 */
25
+	protected $name;
26
+
27
+	/**
28
+	 * @var string mime type
29
+	 */
30
+	protected $type;
31
+
32
+	/**
33
+	 * @var string file extension
34
+	 */
35
+	protected $extension;
36
+
37
+	/**
38
+	 * @var int in bytes
39
+	 */
40
+	protected $size;
41
+
42
+	/**
43
+	 * @var string local filepath to the temporary file
44
+	 */
45
+	protected $tmp_file;
46
+
47
+	/**
48
+	 * @var int one of UPLOAD_ERR_OK, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE or other values
49
+	 * although those aren't expected.
50
+	 */
51
+	protected $error_code;
52
+
53
+	/**
54
+	 * FileSubmission constructor.
55
+	 * @param $name
56
+	 * @param $tmp_file
57
+	 * @param $size
58
+	 * @param null $error_code
59
+	 * @throws InvalidArgumentException
60
+	 */
61
+	public function __construct($name, $tmp_file, $size, $error_code = null)
62
+	{
63
+		$this->name = basename($name);
64
+		if (parse_url($tmp_file, PHP_URL_SCHEME)) {
65
+			// Wait a minute- just local filepaths please, no URL schemes allowed!
66
+			throw new InvalidArgumentException(
67
+				sprintf(
68
+					// @codingStandardsIgnoreStart
69
+					esc_html__('The filepath of the temporary file ("%1$s") indicates is located elsewhere, that’s not ok!', 'event_espresso'),
70
+					// @codingStandardsIgnoreEnd
71
+					$tmp_file
72
+				)
73
+			);
74
+		}
75
+		$this->tmp_file = (string) $tmp_file;
76
+		$this->size = (int) $size;
77
+		$this->error_code = (int) $error_code;
78
+	}
79
+
80
+	/**
81
+	 * @return string
82
+	 */
83
+	public function getName()
84
+	{
85
+		return $this->name;
86
+	}
87
+
88
+	/**
89
+	 * Gets the file's mime type
90
+	 * @return string
91
+	 */
92
+	public function getType()
93
+	{
94
+		if (!$this->type) {
95
+			$this->type = $this->determineType();
96
+		}
97
+		return $this->type;
98
+	}
99
+
100
+	/**
101
+	 * @since $VID:$
102
+	 * @return string
103
+	 */
104
+	protected function determineType()
105
+	{
106
+		if (!$this->getTmpFile()) {
107
+			return '';
108
+		}
109
+		$finfo = new finfo(FILEINFO_MIME_TYPE);
110
+		return $finfo->file($this->getTmpFile());
111
+	}
112
+
113
+	/**
114
+	 * Gets the file's extension.
115
+	 * @since $VID:$
116
+	 * @return string
117
+	 */
118
+	public function getExtension()
119
+	{
120
+		if (!$this->extension) {
121
+			$this->extension = $this->determineExtension();
122
+		}
123
+		return $this->extension;
124
+	}
125
+
126
+	/**
127
+	 * Determine's the file's extension given the temporary file.
128
+	 * @since $VID:$
129
+	 * @return string
130
+	 */
131
+	protected function determineExtension()
132
+	{
133
+		if (!$this->getTmpFile()) {
134
+			return '';
135
+		}
136
+		return pathinfo($this->getTmpFile(), PATHINFO_EXTENSION);
137
+	}
138
+
139
+	/**
140
+	 * Gets the size of the file
141
+	 * @return int
142
+	 */
143
+	public function getSize()
144
+	{
145
+		return $this->size;
146
+	}
147
+
148
+	/**
149
+	 * Gets the path to the temporary file which was uploaded.
150
+	 * @return string
151
+	 */
152
+	public function getTmpFile()
153
+	{
154
+		return $this->tmp_file;
155
+	}
156
+
157
+	/**
158
+	 * @since $VID:$
159
+	 * @return string
160
+	 */
161
+	public function __toString()
162
+	{
163
+		return $this->getTmpFile();
164
+	}
165
+
166
+	/**
167
+	 * Gets the error code PHP reported for the file upload.
168
+	 * @return string
169
+	 */
170
+	public function getErrorCode()
171
+	{
172
+		return $this->error_code;
173
+	}
174 174
 }
175 175
 // End of file FileSubmission.php
176 176
 // Location: EventEspresso\core\services\request\files/FileSubmission.php
Please login to merge, or discard this patch.
core/services/request/files/FilesDataHandler.php 3 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function getFileObjects()
78 78
     {
79
-        if (!$this->initialized) {
79
+        if ( ! $this->initialized) {
80 80
             $this->initialize();
81 81
         }
82 82
         return $this->file_objects;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
      */
112 112
     protected function isStrangeFilesArray($files_data)
113 113
     {
114
-        if (!is_array($files_data)) {
114
+        if ( ! is_array($files_data)) {
115 115
             throw new UnexpectedValueException(
116 116
                 sprintf(
117 117
                     esc_html__(
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
             );
124 124
         }
125 125
         $first_value = reset($files_data);
126
-        if (!is_array($first_value)) {
126
+        if ( ! is_array($first_value)) {
127 127
             throw new UnexpectedValueException(
128 128
                 sprintf(
129 129
                     esc_html__(
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
         $organized_data = [];
186 186
         foreach ($data as $key => $val) {
187 187
             if (is_array($val)) {
188
-                $organized_data[ $key ] = $this->organizeFilesData($val, $type);
188
+                $organized_data[$key] = $this->organizeFilesData($val, $type);
189 189
             } else {
190
-                $organized_data[ $key ][ $type ] = $val;
190
+                $organized_data[$key][$type] = $val;
191 191
             }
192 192
         }
193 193
         return $organized_data;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
      */
205 205
     protected function createFileObjects($organized_files)
206 206
     {
207
-        if (!is_array($organized_files)) {
207
+        if ( ! is_array($organized_files)) {
208 208
             throw new UnexpectedValueException(
209 209
                 sprintf(
210 210
                     esc_html__(
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
         $objs = [];
219 219
         foreach ($organized_files as $key => $value) {
220 220
             if (isset($value['name'], $value['tmp_name'], $value['size'])) {
221
-                $objs[ $key ] = new FileSubmission(
221
+                $objs[$key] = new FileSubmission(
222 222
                     $value['name'],
223 223
                     $value['tmp_name'],
224 224
                     $value['size'],
225 225
                     $value['error']
226 226
                 );
227 227
             } else {
228
-                $objs[ $key ] = $this->createFileObjects($value);
228
+                $objs[$key] = $this->createFileObjects($value);
229 229
             }
230 230
         }
231 231
         return $objs;
Please login to merge, or discard this patch.
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -2,11 +2,6 @@
 block discarded – undo
2 2
 
3 3
 namespace EventEspresso\core\services\request\files;
4 4
 
5
-use EventEspresso\core\services\collections\CollectionDetails;
6
-use EventEspresso\core\services\collections\CollectionDetailsException;
7
-use EventEspresso\core\services\collections\CollectionInterface;
8
-use EventEspresso\core\services\collections\CollectionLoader;
9
-use EventEspresso\core\services\collections\CollectionLoaderException;
10 5
 use EventEspresso\core\services\request\Request;
11 6
 use InvalidArgumentException;
12 7
 use UnexpectedValueException;
Please login to merge, or discard this patch.
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -43,195 +43,195 @@
 block discarded – undo
43 43
  */
44 44
 class FilesDataHandler
45 45
 {
46
-    /**
47
-     * @var Request
48
-     */
49
-    protected $request;
46
+	/**
47
+	 * @var Request
48
+	 */
49
+	protected $request;
50 50
 
51
-    /**
52
-     * @var array
53
-     */
54
-    protected $file_objects;
51
+	/**
52
+	 * @var array
53
+	 */
54
+	protected $file_objects;
55 55
 
56
-    /**
57
-     * @var bool
58
-     */
59
-    protected $initialized = false;
56
+	/**
57
+	 * @var bool
58
+	 */
59
+	protected $initialized = false;
60 60
 
61
-    /**
62
-     * FilesDataHandler constructor.
63
-     * @param Request $request
64
-     */
65
-    public function __construct(Request $request)
66
-    {
67
-        $this->request = $request;
68
-    }
61
+	/**
62
+	 * FilesDataHandler constructor.
63
+	 * @param Request $request
64
+	 */
65
+	public function __construct(Request $request)
66
+	{
67
+		$this->request = $request;
68
+	}
69 69
 
70
-    /**
71
-     * @since $VID:$
72
-     * @return array with a similar structure to $_POST and $_GET (ie, it can be multi-dimensional) but the "leaf"
73
-     * nodes are all of type FileSubmissionInterface
74
-     * @throws UnexpectedValueException
75
-     * @throws InvalidArgumentException
76
-     */
77
-    public function getFileObjects()
78
-    {
79
-        if (!$this->initialized) {
80
-            $this->initialize();
81
-        }
82
-        return $this->file_objects;
83
-    }
70
+	/**
71
+	 * @since $VID:$
72
+	 * @return array with a similar structure to $_POST and $_GET (ie, it can be multi-dimensional) but the "leaf"
73
+	 * nodes are all of type FileSubmissionInterface
74
+	 * @throws UnexpectedValueException
75
+	 * @throws InvalidArgumentException
76
+	 */
77
+	public function getFileObjects()
78
+	{
79
+		if (!$this->initialized) {
80
+			$this->initialize();
81
+		}
82
+		return $this->file_objects;
83
+	}
84 84
 
85
-    /**
86
-     * Sets up the file objects from the request's $_FILES data.
87
-     * @since $VID:$
88
-     * @throws UnexpectedValueException
89
-     * @throws InvalidArgumentException
90
-     */
91
-    protected function initialize()
92
-    {
93
-        $files_raw_data = $this->request->filesParams();
94
-        if (empty($files_raw_data)) {
95
-            return;
96
-        }
97
-        if ($this->isStrangeFilesArray($files_raw_data)) {
98
-            $data = $this->fixFilesDataArray($files_raw_data);
99
-        } else {
100
-            $data = $files_raw_data;
101
-        }
102
-        $this->file_objects = $this->createFileObjects($data);
103
-        $this->initialized = true;
104
-    }
85
+	/**
86
+	 * Sets up the file objects from the request's $_FILES data.
87
+	 * @since $VID:$
88
+	 * @throws UnexpectedValueException
89
+	 * @throws InvalidArgumentException
90
+	 */
91
+	protected function initialize()
92
+	{
93
+		$files_raw_data = $this->request->filesParams();
94
+		if (empty($files_raw_data)) {
95
+			return;
96
+		}
97
+		if ($this->isStrangeFilesArray($files_raw_data)) {
98
+			$data = $this->fixFilesDataArray($files_raw_data);
99
+		} else {
100
+			$data = $files_raw_data;
101
+		}
102
+		$this->file_objects = $this->createFileObjects($data);
103
+		$this->initialized = true;
104
+	}
105 105
 
106
-    /**
107
-     * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
108
-     * @since $VID:$
109
-     * @param $files_data
110
-     * @return bool
111
-     * @throws UnexpectedValueException
112
-     */
113
-    protected function isStrangeFilesArray($files_data)
114
-    {
115
-        if (!is_array($files_data)) {
116
-            throw new UnexpectedValueException(
117
-                sprintf(
118
-                    esc_html__(
119
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
120
-                        'event_espresso'
121
-                    ),
122
-                    (string) $files_data
123
-                )
124
-            );
125
-        }
126
-        $first_value = reset($files_data);
127
-        if (!is_array($first_value)) {
128
-            throw new UnexpectedValueException(
129
-                sprintf(
130
-                    esc_html__(
131
-                        'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
132
-                        'event_espresso'
133
-                    ),
134
-                    (string) $first_value
135
-                )
136
-            );
137
-        }
138
-        $first_sub_array_item = reset($first_value);
139
-        if (is_array($first_sub_array_item)) {
140
-            // not just a 2d array
141
-            return true;
142
-        }
143
-        // yep, just 2d array
144
-        return false;
145
-    }
106
+	/**
107
+	 * Detects if $_FILES is a weird multi-dimensional array that needs fixing or not.
108
+	 * @since $VID:$
109
+	 * @param $files_data
110
+	 * @return bool
111
+	 * @throws UnexpectedValueException
112
+	 */
113
+	protected function isStrangeFilesArray($files_data)
114
+	{
115
+		if (!is_array($files_data)) {
116
+			throw new UnexpectedValueException(
117
+				sprintf(
118
+					esc_html__(
119
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
120
+						'event_espresso'
121
+					),
122
+					(string) $files_data
123
+				)
124
+			);
125
+		}
126
+		$first_value = reset($files_data);
127
+		if (!is_array($first_value)) {
128
+			throw new UnexpectedValueException(
129
+				sprintf(
130
+					esc_html__(
131
+						'Unexpected PHP $_FILES data format. "%1$s" was expected to be an array.',
132
+						'event_espresso'
133
+					),
134
+					(string) $first_value
135
+				)
136
+			);
137
+		}
138
+		$first_sub_array_item = reset($first_value);
139
+		if (is_array($first_sub_array_item)) {
140
+			// not just a 2d array
141
+			return true;
142
+		}
143
+		// yep, just 2d array
144
+		return false;
145
+	}
146 146
 
147
-    /**
148
-     * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
149
-     * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
150
-     * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
151
-     * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
152
-     * @since $VID:$
153
-     * @param $files_data
154
-     * @return array
155
-     */
156
-    protected function fixFilesDataArray($files_data)
157
-    {
158
-        $sane_files_array = [];
159
-        foreach ($files_data as $top_key => $top_key_avlue) {
160
-            foreach ($top_key_avlue as $lower_key => $lower_key_value) {
161
-                foreach ($lower_key_value as $lowest_key => $lowest_key_value) {
162
-                    $next_data = [
163
-                        $top_key => [
164
-                            $lowest_key => $this->organizeFilesData($lowest_key_value, $lower_key, $lowest_key)
165
-                        ]
166
-                    ];
167
-                    $sane_files_array = array_merge_recursive(
168
-                        $sane_files_array,
169
-                        $next_data
170
-                    );
171
-                }
172
-            }
173
-        }
174
-        return $sane_files_array;
175
-    }
147
+	/**
148
+	 * Takes into account that $_FILES does a weird thing when you have hierarchical form names (eg `<input type="file"
149
+	 * name="my[hierarchical][form]">`): it leaves the top-level form part alone, but replaces the SECOND part with
150
+	 * "name", "size", "tmp_name", etc. So that file's data is located at "my[name][hierarchical][form]",
151
+	 * "my[size][hierarchical][form]", "my[tmp_name][hierarchical][form]", etc. It's really weird.
152
+	 * @since $VID:$
153
+	 * @param $files_data
154
+	 * @return array
155
+	 */
156
+	protected function fixFilesDataArray($files_data)
157
+	{
158
+		$sane_files_array = [];
159
+		foreach ($files_data as $top_key => $top_key_avlue) {
160
+			foreach ($top_key_avlue as $lower_key => $lower_key_value) {
161
+				foreach ($lower_key_value as $lowest_key => $lowest_key_value) {
162
+					$next_data = [
163
+						$top_key => [
164
+							$lowest_key => $this->organizeFilesData($lowest_key_value, $lower_key, $lowest_key)
165
+						]
166
+					];
167
+					$sane_files_array = array_merge_recursive(
168
+						$sane_files_array,
169
+						$next_data
170
+					);
171
+				}
172
+			}
173
+		}
174
+		return $sane_files_array;
175
+	}
176 176
 
177
-    /**
178
-     * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
179
-     * @since $VID:$
180
-     * @param $data either 'name', 'tmp_name', 'size', or 'error'
181
-     * @param $type
182
-     * @return array
183
-     */
184
-    protected function organizeFilesData($data, $type)
185
-    {
186
-        $organized_data = [];
187
-        foreach ($data as $key => $val) {
188
-            if (is_array($val)) {
189
-                $organized_data[ $key ] = $this->organizeFilesData($val, $type);
190
-            } else {
191
-                $organized_data[ $key ][ $type ] = $val;
192
-            }
193
-        }
194
-        return $organized_data;
195
-    }
177
+	/**
178
+	 * Recursively explores the array until it finds a leaf node, and tacks `$type` as a final index in front of it.
179
+	 * @since $VID:$
180
+	 * @param $data either 'name', 'tmp_name', 'size', or 'error'
181
+	 * @param $type
182
+	 * @return array
183
+	 */
184
+	protected function organizeFilesData($data, $type)
185
+	{
186
+		$organized_data = [];
187
+		foreach ($data as $key => $val) {
188
+			if (is_array($val)) {
189
+				$organized_data[ $key ] = $this->organizeFilesData($val, $type);
190
+			} else {
191
+				$organized_data[ $key ][ $type ] = $val;
192
+			}
193
+		}
194
+		return $organized_data;
195
+	}
196 196
 
197
-    /**
198
-     * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
199
-     * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
200
-     * multi-dimensional array of FileSubmissionInterface objects.
201
-     * @since $VID:$
202
-     * @param $organized_files
203
-     * @return array
204
-     * @throws UnexpectedValueException
205
-     * @throws InvalidArgumentException
206
-     */
207
-    protected function createFileObjects($organized_files)
208
-    {
209
-        if (!is_array($organized_files)) {
210
-            throw new UnexpectedValueException(
211
-                sprintf(
212
-                    esc_html__(
213
-                        'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
214
-                        'event_espresso'
215
-                    ),
216
-                    (string) $organized_files
217
-                )
218
-            );
219
-        }
220
-        $objs = [];
221
-        foreach ($organized_files as $key => $value) {
222
-            if (isset($value['name'], $value['tmp_name'], $value['size'])) {
223
-                $objs[ $key ] = new FileSubmission(
224
-                    $value['name'],
225
-                    $value['tmp_name'],
226
-                    $value['size'],
227
-                    $value['error']
228
-                );
229
-            } else {
230
-                $objs[ $key ] = $this->createFileObjects($value);
231
-            }
232
-        }
233
-        return $objs;
234
-    }
197
+	/**
198
+	 * Takes the organized $_FILES array (where all file info is located at the same spot as you'd expect an input
199
+	 * to be in $_GET or $_POST, with all the file's data located side-by-side in an array) and creates a
200
+	 * multi-dimensional array of FileSubmissionInterface objects.
201
+	 * @since $VID:$
202
+	 * @param $organized_files
203
+	 * @return array
204
+	 * @throws UnexpectedValueException
205
+	 * @throws InvalidArgumentException
206
+	 */
207
+	protected function createFileObjects($organized_files)
208
+	{
209
+		if (!is_array($organized_files)) {
210
+			throw new UnexpectedValueException(
211
+				sprintf(
212
+					esc_html__(
213
+						'Unexpected PHP $organized_files data format. "%1$s" was expected to be an array.',
214
+						'event_espresso'
215
+					),
216
+					(string) $organized_files
217
+				)
218
+			);
219
+		}
220
+		$objs = [];
221
+		foreach ($organized_files as $key => $value) {
222
+			if (isset($value['name'], $value['tmp_name'], $value['size'])) {
223
+				$objs[ $key ] = new FileSubmission(
224
+					$value['name'],
225
+					$value['tmp_name'],
226
+					$value['size'],
227
+					$value['error']
228
+				);
229
+			} else {
230
+				$objs[ $key ] = $this->createFileObjects($value);
231
+			}
232
+		}
233
+		return $objs;
234
+	}
235 235
 }
236 236
 // End of file FilesDataHandler.php
237 237
 // Location: EventEspresso\core\services\request\files/FilesDataHandler.php
Please login to merge, or discard this patch.
core/services/request/files/FileSubmissionInterface.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 interface FileSubmissionInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @return string
20
-     */
21
-    public function getName();
22
-
23
-    /**
24
-     * @return string
25
-     */
26
-    public function getType();
27
-
28
-    /**
29
-     * @return int
30
-     */
31
-    public function getSize();
32
-
33
-    /**
34
-     * @return string
35
-     */
36
-    public function getTmpFile();
37
-
38
-    /**
39
-     * @since $VID:$
40
-     * @return string
41
-     */
42
-    public function __toString();
43
-
44
-    /**
45
-     * @return string
46
-     */
47
-    public function getErrorCode();
18
+	/**
19
+	 * @return string
20
+	 */
21
+	public function getName();
22
+
23
+	/**
24
+	 * @return string
25
+	 */
26
+	public function getType();
27
+
28
+	/**
29
+	 * @return int
30
+	 */
31
+	public function getSize();
32
+
33
+	/**
34
+	 * @return string
35
+	 */
36
+	public function getTmpFile();
37
+
38
+	/**
39
+	 * @since $VID:$
40
+	 * @return string
41
+	 */
42
+	public function __toString();
43
+
44
+	/**
45
+	 * @return string
46
+	 */
47
+	public function getErrorCode();
48 48
 }
49 49
 // End of file FileSubmissionInterface.php
50 50
 // Location: EventEspresso\core\services\request\files/FileSubmissionInterface.php
Please login to merge, or discard this patch.