C:\xampp\htdocs\landing\wp-content\plugins\wpforms-lite\src\Helpers\Chain.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php

namespace WPForms\Helpers;

/**
 * Chain monad, useful for chaining certain array or string related functions.
 *
 * @since 1.5.6
 */
class Chain {

    
/**
     * Current value.
     *
     * @since 1.5.6
     *
     * @var mixed
     */
    
private $value;

    
/**
     * Class constructor.
     *
     * @since 1.5.6
     *
     * @param mixed $value Current value to start working with.
     */
    
public function __construct$value ) {

        
$this->value $value;
    }

    
/**
     * Bind some function to value.
     *
     * @since 1.5.6
     *
     * @param mixed $fn Some function.
     *
     * @return Chain
     */
    
public function bind$fn ) {

        
$this->value $fn$this->value );

        return 
$this;
    }

    
/**
     * Get value.
     *
     * @since 1.5.6
     *
     * @return mixed
     */
    
public function value() {

        return 
$this->value;
    }

    
/**
     * Magic call.
     *
     * @since 1.5.6
     *
     * @param string $name Method name.
     * @param array  $params Parameters.
     *
     * @throws \BadFunctionCallException Invalid function is called.
     *
     * @return Chain
     */
    
public function __call$name$params ) {

        if ( 
in_array$name$this->allowed_methods(), true ) ) {

            
$params null === $params ? array() : $params;
            
array_unshift$params$this->value );
            
$this->value call_user_func_array$name$params );

            return 
$this;
        }

        throw new \
BadFunctionCallException"Provided function { $name } is not allowed. See Chain::allowed_methods()." );
    }

    
/**
     * Join array elements with a string.
     *
     * @since 1.5.6
     *
     * @param string $glue Defaults to an empty string.
     *
     * @return Chain
     */
    
public function implode$glue '' ) {

        
$this->value implode$glue$this->value );

        return 
$this;
    }

    
/**
     * Split a string by a string.
     *
     * @since 1.5.6
     *
     * @param string $delimiter The boundary string.
     *
     * @return Chain
     */
    
public function explode$delimiter ) {

        
$this->value explode$delimiter$this->value );

        return 
$this;
    }

    
/**
     * Apply the callback to the elements of the given arrays.
     *
     * @since 1.5.6
     *
     * @param callable $cb Callback.
     *
     * @return Chain
     */
    
public function map$cb ) {

        
$this->value array_map$cb$this->value );

        return 
$this;
    }

    
/**
     * Pop array.
     *
     * @since 1.5.6
     *
     * @return Chain
     */
    
public function pop() {

        
$this->value array_pop$this->value );

        return 
$this;
    }

    
/**
     * Run first or second callback based on a condition.
     *
     * @since 1.5.6
     *
     * @param callable $condition Condition function.
     * @param callable $true_result If condition will return true we run this function.
     * @param callable $false_result If condition will return false we run this function.
     *
     * @return Chain
     */
    
public function iif$condition$true_result$false_result null ) {

        if ( ! 
is_callable$false_result ) ) {
            
$false_result = function() {
                return 
'';
            };
        }
        
$this->value array_map(
            function( 
$el ) use ( $condition$true_result$false_result ) {
                if ( 
call_user_func$condition$el ) ) {
                    return 
call_user_func$true_result$el );
                }
                return 
call_user_func$false_result$el );
            },
            
$this->value
        
);

        return 
$this;
    }

    
/**
     * All allowed methods to work with data.
     *
     * @since 1.5.6
     *
     * @return array
     */
    
public function allowed_methods() {

        return array(
            
'array_change_key_case',
            
'array_chunk',
            
'array_column',
            
'array_combine',
            
'array_count_values',
            
'array_diff_assoc',
            
'array_diff_key',
            
'array_diff_uassoc',
            
'array_diff_ukey',
            
'array_diff',
            
'array_fill_keys',
            
'array_fill',
            
'array_filter',
            
'array_flip',
            
'array_intersect_assoc',
            
'array_intersect_key',
            
'array_intersect_uassoc',
            
'array_intersect_ukey',
            
'array_intersect',
            
'array_key_first',
            
'array_key_last',
            
'array_keys',
            
'array_map',
            
'array_merge_recursive',
            
'array_merge',
            
'array_pad',
            
'array_pop',
            
'array_product',
            
'array_rand',
            
'array_reduce',
            
'array_replace_recursive',
            
'array_replace',
            
'array_reverse',
            
'array_shift',
            
'array_slice',
            
'array_splice',
            
'array_sum',
            
'array_udiff_assoc',
            
'array_udiff_uassoc',
            
'array_udiff',
            
'array_uintersect_assoc',
            
'array_uintersect_uassoc',
            
'array_uintersect',
            
'array_unique',
            
'array_values',
            
'count',
            
'current',
            
'end',
            
'key',
            
'next',
            
'prev',
            
'range',
            
'reset',
            
'implode',
            
'ltrim',
            
'rtrim',
            
'md5',
            
'str_getcsv',
            
'str_ireplace',
            
'str_pad',
            
'str_repeat',
            
'str_rot13',
            
'str_shuffle',
            
'str_split',
            
'str_word_count',
            
'strcasecmp',
            
'strchr',
            
'strcmp',
            
'strcoll',
            
'strcspn',
            
'strip_tags',
            
'stripcslashes',
            
'stripos',
            
'stripslashes',
            
'stristr',
            
'strlen',
            
'strnatcasecmp',
            
'strnatcmp',
            
'strncasecmp',
            
'strncmp',
            
'strpbrk',
            
'strpos',
            
'strrchr',
            
'strrev',
            
'strripos',
            
'strrpos',
            
'strspn',
            
'strstr',
            
'strtok',
            
'strtolower',
            
'strtoupper',
            
'strtr',
            
'substr_compare',
            
'substr_count',
            
'substr_replace',
            
'substr',
            
'trim',
            
'ucfirst',
            
'ucwords',
            
'vfprintf',
            
'vprintf',
            
'vsprintf',
            
'wordwrap',
        );
    }

    
/**
     * Create myself.
     *
     * @since 1.5.6
     *
     * @param mixed $value Current.
     *
     * @return Chain
     */
    
public static function of$value null ) {

        return new 
self$value );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586