Completed
Branch FET-10304-welcome-to-vue (5b2425)
by
unknown
25:35 queued 13:40
created
core/helpers/EEH_Inflector.helper.php 3 patches
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @version $Revision 0.1 $
36 36
  */
37 37
 class EEH_Inflector{
38
-    // ------ CLASS METHODS ------ //
39
-    // ---- Public methods ---- //
40
-    // {{{ pluralize()
38
+	// ------ CLASS METHODS ------ //
39
+	// ---- Public methods ---- //
40
+	// {{{ pluralize()
41 41
 
42 42
 	/**
43 43
 	 * Just calls self::pluralize and strtolower on $word and returns it
@@ -51,319 +51,319 @@  discard block
 block discarded – undo
51 51
 	static function singularize_and_upper( $word ) {
52 52
 		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
53 53
 	}
54
-    /**
55
-     * Pluralizes English nouns.
56
-     *
57
-     * @access public
58
-     * @static
59
-     * @param    string    $word    English noun to pluralize
60
-     * @return string Plural noun
61
-     */
62
-    static function pluralize($word){
63
-        $plural = array(
64
-            '/(quiz)$/i'               => '\1zes',
65
-            '/^(ox)$/i'                => '\1en',
66
-            '/([m|l])ouse$/i'          => '\1ice',
67
-            '/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
-            '/(x|ch|ss|sh)$/i'         => '\1es',
69
-            '/([^aeiouy]|qu)ies$/i'    => '\1y',
70
-            '/([^aeiouy]|qu)y$/i'      => '\1ies',
71
-            '/(hive)$/i'               => '\1s',
72
-            '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
-            '/sis$/i'                  => 'ses',
74
-            '/([ti])um$/i'             => '\1a',
75
-            '/(buffal|tomat)o$/i'      => '\1oes',
76
-            '/(bu)s$/i'                => '\1ses',
77
-            '/(alias|status)/i'        => '\1es',
78
-            '/(octop|vir)us$/i'        => '\1i',
79
-            '/(ax|test)is$/i'          => '\1es',
80
-            '/s$/i'                    => 's',
81
-            '/$/'                      => 's');
82
-
83
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
-
85
-        $irregular = array(
86
-            'person' => 'people',
87
-            'man'    => 'men',
88
-            'child'  => 'children',
89
-            'sex'    => 'sexes',
90
-            'move'   => 'moves');
91
-
92
-        $lowercased_word = strtolower($word);
93
-
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
54
+	/**
55
+	 * Pluralizes English nouns.
56
+	 *
57
+	 * @access public
58
+	 * @static
59
+	 * @param    string    $word    English noun to pluralize
60
+	 * @return string Plural noun
61
+	 */
62
+	static function pluralize($word){
63
+		$plural = array(
64
+			'/(quiz)$/i'               => '\1zes',
65
+			'/^(ox)$/i'                => '\1en',
66
+			'/([m|l])ouse$/i'          => '\1ice',
67
+			'/(matr|vert|ind)ix|ex$/i' => '\1ices',
68
+			'/(x|ch|ss|sh)$/i'         => '\1es',
69
+			'/([^aeiouy]|qu)ies$/i'    => '\1y',
70
+			'/([^aeiouy]|qu)y$/i'      => '\1ies',
71
+			'/(hive)$/i'               => '\1s',
72
+			'/(?:([^f])fe|([lr])f)$/i' => '\1\2ves',
73
+			'/sis$/i'                  => 'ses',
74
+			'/([ti])um$/i'             => '\1a',
75
+			'/(buffal|tomat)o$/i'      => '\1oes',
76
+			'/(bu)s$/i'                => '\1ses',
77
+			'/(alias|status)/i'        => '\1es',
78
+			'/(octop|vir)us$/i'        => '\1i',
79
+			'/(ax|test)is$/i'          => '\1es',
80
+			'/s$/i'                    => 's',
81
+			'/$/'                      => 's');
82
+
83
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
84
+
85
+		$irregular = array(
86
+			'person' => 'people',
87
+			'man'    => 'men',
88
+			'child'  => 'children',
89
+			'sex'    => 'sexes',
90
+			'move'   => 'moves');
91
+
92
+		$lowercased_word = strtolower($word);
93
+
94
+		foreach($uncountable as $_uncountable){
95
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96 96
 					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
97
-                return $word;
98
-            }
99
-        }
100
-
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
-            }
105
-        }
106
-
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
109
-                return preg_replace($rule, $replacement, $word);
110
-            }
111
-        }
112
-        return false;
113
-    }
114
-
115
-    // }}}
116
-    // {{{ singularize()
117
-
118
-    /**
119
-     * Singularizes English nouns.
120
-     *
121
-     * @access public
122
-     * @static
123
-     * @param    string    $word    English noun to singularize
124
-     * @return string Singular noun.
125
-     */
126
-    static function singularize($word){
127
-        $singular = array(
128
-            '/(quiz)zes$/i'                                                    => '\1',
129
-            '/(matr)ices$/i'                                                   => '\1ix',
130
-            '/(vert|ind)ices$/i'                                               => '\1ex',
131
-            '/^(ox)en/i'                                                       => '\1',
132
-            '/(alias|status)es$/i'                                             => '\1',
133
-            '/([octop|vir])i$/i'                                               => '\1us',
134
-            '/(cris|ax|test)es$/i'                                             => '\1is',
135
-            '/(shoe)s$/i'                                                      => '\1',
136
-            '/(o)es$/i'                                                        => '\1',
137
-            '/(bus)es$/i'                                                      => '\1',
138
-            '/([m|l])ice$/i'                                                   => '\1ouse',
139
-            '/(x|ch|ss|sh)es$/i'                                               => '\1',
140
-            '/(m)ovies$/i'                                                     => '\1ovie',
141
-            '/(s)eries$/i'                                                     => '\1eries',
142
-            '/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
-            '/([lr])ves$/i'                                                    => '\1f',
144
-            '/(tive)s$/i'                                                      => '\1',
145
-            '/(hive)s$/i'                                                      => '\1',
146
-            '/([^f])ves$/i'                                                    => '\1fe',
147
-            '/(^analy)ses$/i'                                                  => '\1sis',
148
-            '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
-            '/([ti])a$/i'                                                      => '\1um',
150
-            '/(n)ews$/i'                                                       => '\1ews',
151
-            '/s$/i'                                                            => '',
152
-        );
153
-
154
-        $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
-
156
-        $irregular = array(
157
-            'person' => 'people',
158
-            'man'    => 'men',
159
-            'child'  => 'children',
160
-            'sex'    => 'sexes',
161
-            'move'   => 'moves');
162
-
163
-        $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
-                return $word;
167
-            }
168
-        }
169
-
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
-            }
174
-        }
175
-
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
178
-                return preg_replace($rule, $replacement, $word);
179
-            }
180
-        }
181
-
182
-        return $word;
183
-    }
184
-
185
-    // }}}
186
-    // {{{ titleize()
187
-
188
-    /**
189
-     * Converts an underscored or CamelCase word into a English
190
-     * sentence.
191
-     *
192
-     * The titleize static function converts text like "WelcomePage",
193
-     * "welcome_page" or  "welcome page" to this "Welcome
194
-     * Page".
195
-     * If second parameter is set to 'first' it will only
196
-     * capitalize the first character of the title.
197
-     *
198
-     * @access public
199
-     * @static
200
-     * @param    string    $word    Word to format as tile
201
-     * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
-     * first character. Otherwise it will uppercase all
203
-     * the words in the title.
204
-     * @return string Text formatted as title
205
-     */
206
-    static function titleize($word, $uppercase = ''){
207
-        $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
-        return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
-    }
210
-
211
-    // }}}
212
-    // {{{ camelize()
213
-
214
-    /**
215
-     * Returns given word as CamelCased
216
-     *
217
-     * Converts a word like "send_email" to "SendEmail". It
218
-     * will remove non alphanumeric character from the word, so
219
-     * "who's online" will be converted to "WhoSOnline"
220
-     *
221
-     * @access public
222
-     * @static
223
-     * @see variablize
224
-     * @param    string    $word    Word to convert to camel case
225
-     * @return string UpperCamelCasedWord
226
-     */
227
-    static function camelize($word){
228
-        return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
-    }
230
-
231
-    // }}}
232
-    // {{{ underscore()
233
-
234
-    /**
235
-     * Converts a word "into_it_s_underscored_version"
236
-     *
237
-     * Convert any "CamelCased" or "ordinary Word" into an
238
-     * "underscored_word".
239
-     *
240
-     * This can be really useful for creating friendly URLs.
241
-     *
242
-     * @access public
243
-     * @static
244
-     * @param    string    $word    Word to underscore
245
-     * @return string Underscored word
246
-     */
247
-    static function underscore($word){
248
-        return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
-    }
250
-
251
-    // }}}
252
-    // {{{ humanize()
253
-
254
-    /**
255
-     * Returns a human-readable string from $word
256
-     *
257
-     * Returns a human-readable string from $word, by replacing
258
-     * underscores with a space, and by upper-casing the initial
259
-     * character by default.
260
-     *
261
-     * If you need to uppercase all the words you just have to
262
-     * pass 'all' as a second parameter.
263
-     *
264
-     * @access public
265
-     * @static
266
-     * @param    string    $word    String to "humanize"
267
-     * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
-     * instead of just the first one.
269
-     * @return string Human-readable word
270
-     */
271
-    static function humanize($word, $uppercase = ''){
97
+				return $word;
98
+			}
99
+		}
100
+
101
+		foreach($irregular as $_plural => $_singular){
102
+			if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
+				return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
104
+			}
105
+		}
106
+
107
+		foreach($plural as $rule => $replacement){
108
+			if(preg_match($rule, $word)){
109
+				return preg_replace($rule, $replacement, $word);
110
+			}
111
+		}
112
+		return false;
113
+	}
114
+
115
+	// }}}
116
+	// {{{ singularize()
117
+
118
+	/**
119
+	 * Singularizes English nouns.
120
+	 *
121
+	 * @access public
122
+	 * @static
123
+	 * @param    string    $word    English noun to singularize
124
+	 * @return string Singular noun.
125
+	 */
126
+	static function singularize($word){
127
+		$singular = array(
128
+			'/(quiz)zes$/i'                                                    => '\1',
129
+			'/(matr)ices$/i'                                                   => '\1ix',
130
+			'/(vert|ind)ices$/i'                                               => '\1ex',
131
+			'/^(ox)en/i'                                                       => '\1',
132
+			'/(alias|status)es$/i'                                             => '\1',
133
+			'/([octop|vir])i$/i'                                               => '\1us',
134
+			'/(cris|ax|test)es$/i'                                             => '\1is',
135
+			'/(shoe)s$/i'                                                      => '\1',
136
+			'/(o)es$/i'                                                        => '\1',
137
+			'/(bus)es$/i'                                                      => '\1',
138
+			'/([m|l])ice$/i'                                                   => '\1ouse',
139
+			'/(x|ch|ss|sh)es$/i'                                               => '\1',
140
+			'/(m)ovies$/i'                                                     => '\1ovie',
141
+			'/(s)eries$/i'                                                     => '\1eries',
142
+			'/([^aeiouy]|qu)ies$/i'                                            => '\1y',
143
+			'/([lr])ves$/i'                                                    => '\1f',
144
+			'/(tive)s$/i'                                                      => '\1',
145
+			'/(hive)s$/i'                                                      => '\1',
146
+			'/([^f])ves$/i'                                                    => '\1fe',
147
+			'/(^analy)ses$/i'                                                  => '\1sis',
148
+			'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
149
+			'/([ti])a$/i'                                                      => '\1um',
150
+			'/(n)ews$/i'                                                       => '\1ews',
151
+			'/s$/i'                                                            => '',
152
+		);
153
+
154
+		$uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep');
155
+
156
+		$irregular = array(
157
+			'person' => 'people',
158
+			'man'    => 'men',
159
+			'child'  => 'children',
160
+			'sex'    => 'sexes',
161
+			'move'   => 'moves');
162
+
163
+		$lowercased_word = strtolower($word);
164
+		foreach($uncountable as $_uncountable){
165
+			if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
166
+				return $word;
167
+			}
168
+		}
169
+
170
+		foreach($irregular as $_plural => $_singular){
171
+			if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
+				return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
173
+			}
174
+		}
175
+
176
+		foreach($singular as $rule => $replacement){
177
+			if(preg_match($rule, $word)){
178
+				return preg_replace($rule, $replacement, $word);
179
+			}
180
+		}
181
+
182
+		return $word;
183
+	}
184
+
185
+	// }}}
186
+	// {{{ titleize()
187
+
188
+	/**
189
+	 * Converts an underscored or CamelCase word into a English
190
+	 * sentence.
191
+	 *
192
+	 * The titleize static function converts text like "WelcomePage",
193
+	 * "welcome_page" or  "welcome page" to this "Welcome
194
+	 * Page".
195
+	 * If second parameter is set to 'first' it will only
196
+	 * capitalize the first character of the title.
197
+	 *
198
+	 * @access public
199
+	 * @static
200
+	 * @param    string    $word    Word to format as tile
201
+	 * @param    string    $uppercase    If set to 'first' it will only uppercase the
202
+	 * first character. Otherwise it will uppercase all
203
+	 * the words in the title.
204
+	 * @return string Text formatted as title
205
+	 */
206
+	static function titleize($word, $uppercase = ''){
207
+		$uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208
+		return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209
+	}
210
+
211
+	// }}}
212
+	// {{{ camelize()
213
+
214
+	/**
215
+	 * Returns given word as CamelCased
216
+	 *
217
+	 * Converts a word like "send_email" to "SendEmail". It
218
+	 * will remove non alphanumeric character from the word, so
219
+	 * "who's online" will be converted to "WhoSOnline"
220
+	 *
221
+	 * @access public
222
+	 * @static
223
+	 * @see variablize
224
+	 * @param    string    $word    Word to convert to camel case
225
+	 * @return string UpperCamelCasedWord
226
+	 */
227
+	static function camelize($word){
228
+		return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229
+	}
230
+
231
+	// }}}
232
+	// {{{ underscore()
233
+
234
+	/**
235
+	 * Converts a word "into_it_s_underscored_version"
236
+	 *
237
+	 * Convert any "CamelCased" or "ordinary Word" into an
238
+	 * "underscored_word".
239
+	 *
240
+	 * This can be really useful for creating friendly URLs.
241
+	 *
242
+	 * @access public
243
+	 * @static
244
+	 * @param    string    $word    Word to underscore
245
+	 * @return string Underscored word
246
+	 */
247
+	static function underscore($word){
248
+		return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249
+	}
250
+
251
+	// }}}
252
+	// {{{ humanize()
253
+
254
+	/**
255
+	 * Returns a human-readable string from $word
256
+	 *
257
+	 * Returns a human-readable string from $word, by replacing
258
+	 * underscores with a space, and by upper-casing the initial
259
+	 * character by default.
260
+	 *
261
+	 * If you need to uppercase all the words you just have to
262
+	 * pass 'all' as a second parameter.
263
+	 *
264
+	 * @access public
265
+	 * @static
266
+	 * @param    string    $word    String to "humanize"
267
+	 * @param    string    $uppercase    If set to 'all' it will uppercase all the words
268
+	 * instead of just the first one.
269
+	 * @return string Human-readable word
270
+	 */
271
+	static function humanize($word, $uppercase = ''){
272 272
 		//make special exceptions for acronyms
273 273
 		$word = str_replace('wp_', 'WP_', $word );
274
-        $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
-        return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
-    }
277
-
278
-    // }}}
279
-    // {{{ variablize()
280
-
281
-    /**
282
-     * Same as camelize but first char is underscored
283
-     *
284
-     * Converts a word like "send_email" to "sendEmail". It
285
-     * will remove non alphanumeric character from the word, so
286
-     * "who's online" will be converted to "whoSOnline"
287
-     *
288
-     * @access public
289
-     * @static
290
-     * @see camelize
291
-     * @param    string    $word    Word to lowerCamelCase
292
-     * @return string Returns a lowerCamelCasedWord
293
-     */
294
-    static function variablize($word){
295
-        $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
297
-    }
298
-
299
-    // }}}
300
-    // {{{ tableize()
301
-
302
-    /**
303
-     * Converts a class name to its table name according to rails
304
-     * naming conventions.
305
-     *
306
-     * Converts "Person" to "people"
307
-     *
308
-     * @access public
309
-     * @static
310
-     * @see classify
311
-     * @param    string    $class_name    Class name for getting related table_name.
312
-     * @return string plural_table_name
313
-     */
314
-    static function tableize($class_name){
315
-        return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
-    }
317
-
318
-    // }}}
319
-    // {{{ classify()
320
-
321
-    /**
322
-     * Converts a table name to its class name according to rails
323
-     * naming conventions.
324
-     *
325
-     * Converts "people" to "Person"
326
-     *
327
-     * @access public
328
-     * @static
329
-     * @see tableize
330
-     * @param    string    $table_name    Table name for getting related ClassName.
331
-     * @return string SingularClassName
332
-     */
333
-    static function classify($table_name){
334
-        return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
-    }
336
-
337
-    // }}}
338
-    // {{{ ordinalize()
339
-
340
-    /**
341
-     * Converts number to its ordinal English form.
342
-     *
343
-     * This method converts 13 to 13th, 2 to 2nd ...
344
-     *
345
-     * @access public
346
-     * @static
347
-     * @param    integer    $number    Number to get its ordinal value
348
-     * @return string Ordinal representation of given string.
349
-     */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
355
-                case 1:
356
-                    return $number . 'st';
357
-                    break;
358
-                case 2:
359
-                    return $number . 'nd';
360
-                    break;
361
-                case 3:
362
-                    return $number . 'rd';
363
-                default:
364
-                    return $number . 'th';
365
-                    break;
366
-            }
367
-        }
368
-    }
274
+		$uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275
+		return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276
+	}
277
+
278
+	// }}}
279
+	// {{{ variablize()
280
+
281
+	/**
282
+	 * Same as camelize but first char is underscored
283
+	 *
284
+	 * Converts a word like "send_email" to "sendEmail". It
285
+	 * will remove non alphanumeric character from the word, so
286
+	 * "who's online" will be converted to "whoSOnline"
287
+	 *
288
+	 * @access public
289
+	 * @static
290
+	 * @see camelize
291
+	 * @param    string    $word    Word to lowerCamelCase
292
+	 * @return string Returns a lowerCamelCasedWord
293
+	 */
294
+	static function variablize($word){
295
+		$word = EEH_Inflector::camelize($word);
296
+		return strtolower($word[0]) . substr($word, 1);
297
+	}
298
+
299
+	// }}}
300
+	// {{{ tableize()
301
+
302
+	/**
303
+	 * Converts a class name to its table name according to rails
304
+	 * naming conventions.
305
+	 *
306
+	 * Converts "Person" to "people"
307
+	 *
308
+	 * @access public
309
+	 * @static
310
+	 * @see classify
311
+	 * @param    string    $class_name    Class name for getting related table_name.
312
+	 * @return string plural_table_name
313
+	 */
314
+	static function tableize($class_name){
315
+		return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316
+	}
317
+
318
+	// }}}
319
+	// {{{ classify()
320
+
321
+	/**
322
+	 * Converts a table name to its class name according to rails
323
+	 * naming conventions.
324
+	 *
325
+	 * Converts "people" to "Person"
326
+	 *
327
+	 * @access public
328
+	 * @static
329
+	 * @see tableize
330
+	 * @param    string    $table_name    Table name for getting related ClassName.
331
+	 * @return string SingularClassName
332
+	 */
333
+	static function classify($table_name){
334
+		return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335
+	}
336
+
337
+	// }}}
338
+	// {{{ ordinalize()
339
+
340
+	/**
341
+	 * Converts number to its ordinal English form.
342
+	 *
343
+	 * This method converts 13 to 13th, 2 to 2nd ...
344
+	 *
345
+	 * @access public
346
+	 * @static
347
+	 * @param    integer    $number    Number to get its ordinal value
348
+	 * @return string Ordinal representation of given string.
349
+	 */
350
+	static function ordinalize($number){
351
+		if(in_array(($number % 100), range(11, 13))){
352
+			return $number . 'th';
353
+		}else{
354
+			switch(($number % 10)){
355
+				case 1:
356
+					return $number . 'st';
357
+					break;
358
+				case 2:
359
+					return $number . 'nd';
360
+					break;
361
+				case 3:
362
+					return $number . 'rd';
363
+				default:
364
+					return $number . 'th';
365
+					break;
366
+			}
367
+		}
368
+	}
369 369
 }
370 370
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 // +----------------------------------------------------------------------+
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
  * @since 0.1
35 35
  * @version $Revision 0.1 $
36 36
  */
37
-class EEH_Inflector{
37
+class EEH_Inflector {
38 38
     // ------ CLASS METHODS ------ //
39 39
     // ---- Public methods ---- //
40 40
     // {{{ pluralize()
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 * @param string $word
45 45
 	 * @return string
46 46
 	 */
47
-	static function pluralize_and_lower( $word ){
48
-		return strtolower( self::pluralize( $word ) );
47
+	static function pluralize_and_lower($word) {
48
+		return strtolower(self::pluralize($word));
49 49
 	}
50 50
 
51
-	static function singularize_and_upper( $word ) {
52
-		return str_replace( ' ', '_', self::humanize( self::singularize( $word ), 'all' ) );
51
+	static function singularize_and_upper($word) {
52
+		return str_replace(' ', '_', self::humanize(self::singularize($word), 'all'));
53 53
 	}
54 54
     /**
55 55
      * Pluralizes English nouns.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      * @param    string    $word    English noun to pluralize
60 60
      * @return string Plural noun
61 61
      */
62
-    static function pluralize($word){
62
+    static function pluralize($word) {
63 63
         $plural = array(
64 64
             '/(quiz)$/i'               => '\1zes',
65 65
             '/^(ox)$/i'                => '\1en',
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 
92 92
         $lowercased_word = strtolower($word);
93 93
 
94
-        foreach($uncountable as $_uncountable){
95
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
-					! ctype_alpha( $lowercased_word[ strlen( $lowercased_word ) - strlen($_uncountable) ] ) ){
94
+        foreach ($uncountable as $_uncountable) {
95
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable && //even though the word "price" ends in "rice", it can be pluralized, so check the previous character isnt a letter
96
+					! ctype_alpha($lowercased_word[strlen($lowercased_word) - strlen($_uncountable)])) {
97 97
                 return $word;
98 98
             }
99 99
         }
100 100
 
101
-        foreach($irregular as $_plural => $_singular){
102
-            if(preg_match('/(' . $_plural . ')$/i', $word, $arr)){
103
-                return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word);
101
+        foreach ($irregular as $_plural => $_singular) {
102
+            if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
103
+                return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
104 104
             }
105 105
         }
106 106
 
107
-        foreach($plural as $rule => $replacement){
108
-            if(preg_match($rule, $word)){
107
+        foreach ($plural as $rule => $replacement) {
108
+            if (preg_match($rule, $word)) {
109 109
                 return preg_replace($rule, $replacement, $word);
110 110
             }
111 111
         }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      * @param    string    $word    English noun to singularize
124 124
      * @return string Singular noun.
125 125
      */
126
-    static function singularize($word){
126
+    static function singularize($word) {
127 127
         $singular = array(
128 128
             '/(quiz)zes$/i'                                                    => '\1',
129 129
             '/(matr)ices$/i'                                                   => '\1ix',
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
             'move'   => 'moves');
162 162
 
163 163
         $lowercased_word = strtolower($word);
164
-        foreach($uncountable as $_uncountable){
165
-            if(substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable){
164
+        foreach ($uncountable as $_uncountable) {
165
+            if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) {
166 166
                 return $word;
167 167
             }
168 168
         }
169 169
 
170
-        foreach($irregular as $_plural => $_singular){
171
-            if(preg_match('/(' . $_singular . ')$/i', $word, $arr)){
172
-                return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word);
170
+        foreach ($irregular as $_plural => $_singular) {
171
+            if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
172
+                return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
173 173
             }
174 174
         }
175 175
 
176
-        foreach($singular as $rule => $replacement){
177
-            if(preg_match($rule, $word)){
176
+        foreach ($singular as $rule => $replacement) {
177
+            if (preg_match($rule, $word)) {
178 178
                 return preg_replace($rule, $replacement, $word);
179 179
             }
180 180
         }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * the words in the title.
204 204
      * @return string Text formatted as title
205 205
      */
206
-    static function titleize($word, $uppercase = ''){
206
+    static function titleize($word, $uppercase = '') {
207 207
         $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords';
208 208
         return $uppercase(EEH_Inflector::humanize(EEH_Inflector::underscore($word)));
209 209
     }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      * @param    string    $word    Word to convert to camel case
225 225
      * @return string UpperCamelCasedWord
226 226
      */
227
-    static function camelize($word){
227
+    static function camelize($word) {
228 228
         return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
229 229
     }
230 230
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      * @param    string    $word    Word to underscore
245 245
      * @return string Underscored word
246 246
      */
247
-    static function underscore($word){
247
+    static function underscore($word) {
248 248
         return strtolower(preg_replace('/[^A-Z^a-z^0-9]+/', '_', preg_replace('/([a-zd])([A-Z])/', '1_2', preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word))));
249 249
     }
250 250
 
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
      * instead of just the first one.
269 269
      * @return string Human-readable word
270 270
      */
271
-    static function humanize($word, $uppercase = ''){
271
+    static function humanize($word, $uppercase = '') {
272 272
 		//make special exceptions for acronyms
273
-		$word = str_replace('wp_', 'WP_', $word );
273
+		$word = str_replace('wp_', 'WP_', $word);
274 274
         $uppercase = $uppercase == 'all' ? 'ucwords' : 'ucfirst';
275 275
         return $uppercase(str_replace('_', ' ', preg_replace('/_id$/', '', $word)));
276 276
     }
@@ -291,9 +291,9 @@  discard block
 block discarded – undo
291 291
      * @param    string    $word    Word to lowerCamelCase
292 292
      * @return string Returns a lowerCamelCasedWord
293 293
      */
294
-    static function variablize($word){
294
+    static function variablize($word) {
295 295
         $word = EEH_Inflector::camelize($word);
296
-        return strtolower($word[0]) . substr($word, 1);
296
+        return strtolower($word[0]).substr($word, 1);
297 297
     }
298 298
 
299 299
     // }}}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      * @param    string    $class_name    Class name for getting related table_name.
312 312
      * @return string plural_table_name
313 313
      */
314
-    static function tableize($class_name){
314
+    static function tableize($class_name) {
315 315
         return EEH_Inflector::pluralize(EEH_Inflector::underscore($class_name));
316 316
     }
317 317
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      * @param    string    $table_name    Table name for getting related ClassName.
331 331
      * @return string SingularClassName
332 332
      */
333
-    static function classify($table_name){
333
+    static function classify($table_name) {
334 334
         return EEH_Inflector::camelize(EEH_Inflector::singularize($table_name));
335 335
     }
336 336
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
      * @param    integer    $number    Number to get its ordinal value
348 348
      * @return string Ordinal representation of given string.
349 349
      */
350
-    static function ordinalize($number){
351
-        if(in_array(($number % 100), range(11, 13))){
352
-            return $number . 'th';
353
-        }else{
354
-            switch(($number % 10)){
350
+    static function ordinalize($number) {
351
+        if (in_array(($number % 100), range(11, 13))) {
352
+            return $number.'th';
353
+        } else {
354
+            switch (($number % 10)) {
355 355
                 case 1:
356
-                    return $number . 'st';
356
+                    return $number.'st';
357 357
                     break;
358 358
                 case 2:
359
-                    return $number . 'nd';
359
+                    return $number.'nd';
360 360
                     break;
361 361
                 case 3:
362
-                    return $number . 'rd';
362
+                    return $number.'rd';
363 363
                 default:
364
-                    return $number . 'th';
364
+                    return $number.'th';
365 365
                     break;
366 366
             }
367 367
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -350,7 +350,7 @@
 block discarded – undo
350 350
     static function ordinalize($number){
351 351
         if(in_array(($number % 100), range(11, 13))){
352 352
             return $number . 'th';
353
-        }else{
353
+        } else{
354 354
             switch(($number % 10)){
355 355
                 case 1:
356 356
                     return $number . 'st';
Please login to merge, or discard this patch.
core/helpers/EEH_Money.helper.php 3 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,18 +8,18 @@
 block discarded – undo
8 8
  */
9 9
 if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
10 10
  /**
11
- *
12
- * Money helper class.
13
- * This class has helper methods that help with money related conversions and calculations.
14
- *
15
- * @since %VER%
16
- *
17
- * @package		Event Espresso
18
- * @subpackage	helpers
19
- * @author		Darren Ethier
20
- *
21
- * ------------------------------------------------------------------------
22
- */
11
+  *
12
+  * Money helper class.
13
+  * This class has helper methods that help with money related conversions and calculations.
14
+  *
15
+  * @since %VER%
16
+  *
17
+  * @package		Event Espresso
18
+  * @subpackage	helpers
19
+  * @author		Darren Ethier
20
+  *
21
+  * ------------------------------------------------------------------------
22
+  */
23 23
 class EEH_Money extends EEH_Base  {
24 24
 
25 25
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage plugin api, messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * Use this to register or deregister a new message template pack variation for the EE messages system.
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  *
21 21
  * ------------------------------------------------------------------------
22 22
  */
23
-class EEH_Money extends EEH_Base  {
23
+class EEH_Money extends EEH_Base {
24 24
 
25 25
 
26 26
 	/**
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 * @param int|string $incoming_value
30 30
 	 * @return float
31 31
 	 */
32
-	public static function convert_to_float_from_localized_money( $incoming_value ) {
32
+	public static function convert_to_float_from_localized_money($incoming_value) {
33 33
 		//remove thousands separator
34
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value );
34
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->thsnds, '', $incoming_value);
35 35
 
36 36
 		//replace decimal place with standard decimal.
37
-		$money_value = str_replace( EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value );
37
+		$money_value = str_replace(EE_Registry::instance()->CFG->currency->dec_mrk, '.', $money_value);
38 38
 
39 39
 		//float it! and round to three decimal places
40
-		$money_value = round ( (float) $money_value, 3 );
40
+		$money_value = round((float) $money_value, 3);
41 41
 		return $money_value;
42 42
 	}
43 43
 
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 * @throws \EE_Error
58 58
 	 */
59 59
 
60
-	public static function compare_floats( $float1, $float2, $operator='=' ) {
60
+	public static function compare_floats($float1, $float2, $operator = '=') {
61 61
 		// Check numbers to 5 digits of precision
62 62
 		$epsilon = 0.00001;
63 63
 
64
-		$float1 = (float)$float1;
65
-		$float2 = (float)$float2;
64
+		$float1 = (float) $float1;
65
+		$float2 = (float) $float2;
66 66
 
67 67
 		switch ($operator) {
68 68
 			// equal
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 				}
117 117
 				break;
118 118
 			default:
119
-				throw new EE_Error(__( "Unknown operator '" . $operator . "' in EEH_Money::compare_floats()", 'event_espresso' ) );
119
+				throw new EE_Error(__("Unknown operator '".$operator."' in EEH_Money::compare_floats()", 'event_espresso'));
120 120
 		}
121 121
 
122 122
 		return false;
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return string
133 133
 	 */
134
-	public static function get_format_for_jqplot( $CNT_ISO = '') {
134
+	public static function get_format_for_jqplot($CNT_ISO = '') {
135 135
 		//default format
136 136
 		$format = 'f';
137 137
 		//if CNT_ISO passed lets try to get currency settings for it.
138
-		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null;
138
+		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
139 139
 		//default currency settings for site if not set
140
-		if ( ! $currency_config instanceof EE_Currency_Config ) {
140
+		if ( ! $currency_config instanceof EE_Currency_Config) {
141 141
 			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
142 142
 		}
143 143
 
144 144
 		//first get the decimal place and number of places
145
-		$format = "%'." . $currency_config->dec_plc . $format;
145
+		$format = "%'.".$currency_config->dec_plc.$format;
146 146
 
147 147
 		//currency symbol on right side.
148
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
148
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
149 149
 		return $format;
150 150
 	}
151 151
 
@@ -160,27 +160,27 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @return string
162 162
 	 */
163
-	public static function get_format_for_google_charts( $CNT_ISO = '' ) {
163
+	public static function get_format_for_google_charts($CNT_ISO = '') {
164 164
 		//if CNT_ISO passed lets try to get currency settings for it.
165
-		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : null;
165
+		$currency_config = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
166 166
 		//default currency settings for site if not set
167
-		if ( ! $currency_config instanceof EE_Currency_Config ) {
167
+		if ( ! $currency_config instanceof EE_Currency_Config) {
168 168
 			$currency_config = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
169 169
 		}
170 170
 
171
-		$decimal_places_placeholder = str_pad( '', $currency_config->dec_plc, '0' );
171
+		$decimal_places_placeholder = str_pad('', $currency_config->dec_plc, '0');
172 172
 
173 173
 		//first get the decimal place and number of places
174
-		$format = '#,##0.' . $decimal_places_placeholder;
174
+		$format = '#,##0.'.$decimal_places_placeholder;
175 175
 
176 176
 		//currency symbol on right side.
177
-		$format = $currency_config->sign_b4 ? $currency_config->sign . $format : $format . $currency_config->sign;
177
+		$format = $currency_config->sign_b4 ? $currency_config->sign.$format : $format.$currency_config->sign;
178 178
 		$formatterObject = array(
179 179
 			'decimalSymbol' => $currency_config->dec_mrk,
180 180
 			'groupingSymbol' => $currency_config->thsnds,
181 181
 			'fractionDigits' => $currency_config->dec_plc,
182 182
 		);
183
-		if ( $currency_config->sign_b4 ) {
183
+		if ($currency_config->sign_b4) {
184 184
 			$formatterObject['prefix'] = $currency_config->sign;
185 185
 		} else {
186 186
 			$formatterObject['suffix'] = $currency_config->sign;
Please login to merge, or discard this patch.
core/helpers/EEH_Sideloader.helper.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 
30 30
 
31
-require_once( EE_HELPERS . 'EEH_Base.helper.php' );
31
+require_once(EE_HELPERS.'EEH_Base.helper.php');
32 32
 class EEH_Sideloader extends EEH_Base {
33 33
 
34 34
 	private $_upload_to;
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @access public
44 44
 	 * @param array $init array fo initializing the sideloader if keys match the properties.
45 45
 	 */
46
-	public function __construct( $init = array() ) {
47
-		$this->_init( $init );
46
+	public function __construct($init = array()) {
47
+		$this->_init($init);
48 48
 	}
49 49
 
50 50
 
@@ -55,24 +55,24 @@  discard block
 block discarded – undo
55 55
 	 * @param  array  $init array on init (keys match properties others ignored)
56 56
 	 * @return void
57 57
 	 */
58
-	private function _init( $init ) {
58
+	private function _init($init) {
59 59
 		$defaults = array(
60 60
 			'_upload_to' => $this->_get_wp_uploads_dir(),
61 61
 			'_upload_from' => '',
62 62
 			'_permissions' => 0644,
63
-			'_new_file_name' => 'EE_Sideloader_' . uniqid() . '.default'
63
+			'_new_file_name' => 'EE_Sideloader_'.uniqid().'.default'
64 64
 			);
65 65
 
66
-		$props = array_merge( $defaults, $init );
66
+		$props = array_merge($defaults, $init);
67 67
 
68
-		foreach ( $props as $key => $val ) {
69
-			if ( EEH_Class_Tools::has_property( $this, $key ) ) {
68
+		foreach ($props as $key => $val) {
69
+			if (EEH_Class_Tools::has_property($this, $key)) {
70 70
 				$this->$key = $val;
71 71
 			}
72 72
 		}
73 73
 
74 74
 		//make sure we include the required wp file for needed functions
75
-		require_once( ABSPATH . 'wp-admin/includes/file.php' );
75
+		require_once(ABSPATH.'wp-admin/includes/file.php');
76 76
 	}
77 77
 
78 78
 
@@ -80,16 +80,16 @@  discard block
 block discarded – undo
80 80
 	private function _get_wp_uploads_dir() {}
81 81
 
82 82
 	//setters
83
-	public function set_upload_to( $upload_to_folder ) {
83
+	public function set_upload_to($upload_to_folder) {
84 84
 		$this->_upload_to = $upload_to_folder;
85 85
 	}
86
-	public function set_upload_from( $upload_from_folder ) {
86
+	public function set_upload_from($upload_from_folder) {
87 87
 		$this->_upload_from_folder = $upload_from_folder;
88 88
 	}
89
-	public function set_permissions( $permissions ) {
89
+	public function set_permissions($permissions) {
90 90
 		$this->_permissions = $permissions;
91 91
 	}
92
-	public function set_new_file_name( $new_file_name ) {
92
+	public function set_new_file_name($new_file_name) {
93 93
 		$this->_new_file_name = $new_file_name;
94 94
 	}
95 95
 
@@ -111,34 +111,34 @@  discard block
 block discarded – undo
111 111
 	//upload methods
112 112
 	public function sideload() {
113 113
 		//setup temp dir
114
-		$temp_file = wp_tempnam( $this->_upload_from );
114
+		$temp_file = wp_tempnam($this->_upload_from);
115 115
 
116
-		if ( !$temp_file ) {
117
-			EE_Error::add_error( __('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
116
+		if ( ! $temp_file) {
117
+			EE_Error::add_error(__('Something went wrong with the upload.  Unable to create a tmp file for the uploaded file on the server', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
118 118
 			return false;
119 119
 		}
120 120
 
121
-		do_action( 'AHEE__EEH_Sideloader__sideload__before', $this, $temp_file );
121
+		do_action('AHEE__EEH_Sideloader__sideload__before', $this, $temp_file);
122 122
 
123
-		$wp_remote_args = apply_filters( 'FHEE__EEH_Sideloader__sideload__wp_remote_args', array( 'timeout' => 500, 'stream' => true, 'filename' => $temp_file ), $this, $temp_file );
123
+		$wp_remote_args = apply_filters('FHEE__EEH_Sideloader__sideload__wp_remote_args', array('timeout' => 500, 'stream' => true, 'filename' => $temp_file), $this, $temp_file);
124 124
 
125
-		$response = wp_safe_remote_get( $this->_upload_from, $wp_remote_args );
125
+		$response = wp_safe_remote_get($this->_upload_from, $wp_remote_args);
126 126
 
127
-		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
128
-			unlink( $temp_file );
129
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
130
-				EE_Error::add_error( sprintf( __('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export( $response, true ), $this->_upload_from ), __FILE__, __FUNCTION__, __LINE__ );
127
+		if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) {
128
+			unlink($temp_file);
129
+			if (defined('WP_DEBUG') && WP_DEBUG) {
130
+				EE_Error::add_error(sprintf(__('Unable to upload the file.  Either the path given to upload from is incorrect, or something else happened.  Here is the response returned:<br />%s<br />Here is the path given: %s', 'event_espresso'), var_export($response, true), $this->_upload_from), __FILE__, __FUNCTION__, __LINE__);
131 131
 			}
132 132
 			return false;
133 133
 		}
134 134
 
135 135
 		//possible md5 check
136
-		$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
137
-		if ( $content_md5 ) {
138
-			$md5_check = verify_file_md5( $temp_file, $content_md5 );
139
-			if ( is_wp_error( $md5_check ) ) {
140
-				unlink( $temp_file );
141
-				EE_Error::add_error( $md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
136
+		$content_md5 = wp_remote_retrieve_header($response, 'content-md5');
137
+		if ($content_md5) {
138
+			$md5_check = verify_file_md5($temp_file, $content_md5);
139
+			if (is_wp_error($md5_check)) {
140
+				unlink($temp_file);
141
+				EE_Error::add_error($md5_check->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
142 142
 				return false;
143 143
 			}
144 144
 		}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 		$file = $temp_file;
147 147
 
148 148
 		//now we have the file, let's get it in the right directory with the right name.
149
-		$path = apply_filters( 'FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to . $this->_new_file_name, $this );
149
+		$path = apply_filters('FHEE__EEH_Sideloader__sideload__new_path', $this->_upload_to.$this->_new_file_name, $this);
150 150
 
151 151
 		//move file in
152
-		if ( false === @ rename( $file, $path ) ) {
153
-			unlink( $temp_file );
154
-			EE_Error::add_error(  sprintf( __('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso' ), $path ), __FILE__, __FUNCTION__, __LINE__ );
152
+		if (false === @ rename($file, $path)) {
153
+			unlink($temp_file);
154
+			EE_Error::add_error(sprintf(__('Unable to move the file to new location (possible permissions errors). This is the path the class attempted to move the file to: %s', 'event_espresso'), $path), __FILE__, __FUNCTION__, __LINE__);
155 155
 			return false;
156 156
 		}
157 157
 
158 158
 		//set permissions
159
-		$permissions = apply_filters( 'FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this );
160
-		chmod( $path, $permissions );
159
+		$permissions = apply_filters('FHEE__EEH_Sideloader__sideload__permissions_applied', $this->_permissions, $this);
160
+		chmod($path, $permissions);
161 161
 
162 162
 		//that's it.  let's allow for actions after file uploaded.
163
-		do_action( 'AHEE__EE_Sideloader__sideload_after', $this, $path );
163
+		do_action('AHEE__EE_Sideloader__sideload_after', $this, $path);
164 164
 
165 165
 		//unlink tempfile
166
-		@unlink( $temp_file );
166
+		@unlink($temp_file);
167 167
 		return true;
168 168
 	}
169 169
 
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 2 patches
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -98,8 +99,9 @@  discard block
 block discarded – undo
98 99
 	 * @param array $nav_tabs tab array for nav tabs
99 100
 	 */
100 101
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
101
-		if ( empty($nav_tabs) )
102
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
102
+		if ( empty($nav_tabs) ) {
103
+					throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
104
+		}
103 105
 
104 106
 		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
105 107
 		foreach ( $nav_tabs as $slug => $tab ) {
@@ -165,8 +167,10 @@  discard block
 block discarded – undo
165 167
 	 * @return string                  a html snippet of of all the formatted link elements.
166 168
 	 */
167 169
 	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
168
-		if ( !is_array($item_array) || empty( $item_array ) )
169
-			return false; //get out we don't have even the basic thing we need!
170
+		if ( !is_array($item_array) || empty( $item_array ) ) {
171
+					return false;
172
+		}
173
+		//get out we don't have even the basic thing we need!
170 174
 
171 175
 
172 176
 		$defaults = array(
@@ -184,8 +188,9 @@  discard block
 block discarded – undo
184 188
 			$item = wp_parse_args( $item, $defaults );
185 189
 			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
186 190
 			$list .= self::_text_link_item($item);
187
-			if ( !empty($sep) && $ci != count($item_array) )
188
-				$list .= self::_text_link_item($sep);
191
+			if ( !empty($sep) && $ci != count($item_array) ) {
192
+							$list .= self::_text_link_item($sep);
193
+			}
189 194
 			$ci++;
190 195
 		}
191 196
 
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @return string the assembled html string containing the tabbed content for display.
47 47
 	 * @throws \EE_Error
48 48
 	 */
49
-	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) {
49
+	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) {
50 50
 
51 51
 		//first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
52
-		if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) {
53
-			throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') );
52
+		if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
53
+			throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso'));
54 54
 		}
55 55
 
56 56
 		//make sure we've got incoming data setup properly
57
-		$tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents );
58
-		$tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents;
57
+		$tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents);
58
+		$tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents;
59 59
 
60
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
60
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
61 61
 		$all_tabs_content = '';
62 62
 
63 63
 		$index = 0;
64
-		foreach ( $tabs as $tab ) {
64
+		foreach ($tabs as $tab) {
65 65
 			$active = $index === 0 ? true : false;
66 66
 			$all_tabs .= self::tab($tab, $active);
67 67
 			$all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs';
80 80
 
81
-		return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>';
81
+		return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>';
82 82
 	}
83 83
 
84 84
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 * @throws \EE_Error
103 103
 	 */
104 104
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
105
-		if ( empty($nav_tabs) )
106
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
105
+		if (empty($nav_tabs))
106
+			throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso'));
107 107
 
108
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
109
-		foreach ( $nav_tabs as $slug => $tab ) {
108
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
109
+		foreach ($nav_tabs as $slug => $tab) {
110 110
 			$all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
111 111
 		}
112 112
 		$all_tabs .= '</h2>';
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param bool|string $css If string given then the generated tab will include that as the class.
123 123
 	 * @return string          html for tab
124 124
 	 */
125
-	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) {
125
+	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) {
126 126
 		$name = str_replace(' ', '-', $name);
127 127
 		$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
128
-		$class = $css ? $class . ' ' . $css : $class;
129
-		$nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) );
130
-		$url = $url ? $url : '#' . $name;
131
-		$tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t";
128
+		$class = $css ? $class.' '.$css : $class;
129
+		$nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name));
130
+		$url = $url ? $url : '#'.$name;
131
+		$tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t";
132 132
 		return $tab;
133 133
 	}
134 134
 
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	private static function tab_content($name, $tab_content, $active = false) {
146 146
 		$class = $active ? 'nav-tab-content' : 'nav-tab-content hidden';
147
-		$name = str_replace( ' ', '-', $name);
148
-		$content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n";
149
-		$content .= "\t" . $tab_content . "\n";
147
+		$name = str_replace(' ', '-', $name);
148
+		$content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n";
149
+		$content .= "\t".$tab_content."\n";
150 150
 		$content .= '<div style="clear:both"></div></div>';
151 151
 		return $content;
152 152
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $default 			You can include a string for the item that will receive the "item_display" class for the js.
173 173
 	 * @return string                  a html snippet of of all the formatted link elements.
174 174
 	 */
175
-	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
176
-		$item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class );
177
-		if ( !is_array($item_array) || empty( $item_array ) )
175
+	public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') {
176
+		$item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
177
+		if ( ! is_array($item_array) || empty($item_array))
178 178
 			return false; //get out we don't have even the basic thing we need!
179 179
 
180 180
 
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 			'title' => esc_attr__('Link for Item', 'event_espresso'),
186 186
 			'slug' => 'item_slug'
187 187
 		);
188
-		$container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links';
189
-		$list = '<ul class="' . $container_class . '">';
188
+		$container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links';
189
+		$list = '<ul class="'.$container_class.'">';
190 190
 
191 191
 		$ci = 1;
192
-		foreach ( $item_array as $item ) {
193
-			$item = wp_parse_args( $item, $defaults );
194
-			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
192
+		foreach ($item_array as $item) {
193
+			$item = wp_parse_args($item, $defaults);
194
+			$item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class'];
195 195
 			$list .= self::_text_link_item($item);
196
-			if ( !empty($sep) && $ci != count($item_array) )
196
+			if ( ! empty($sep) && $ci != count($item_array))
197 197
 				$list .= self::_text_link_item($sep);
198 198
 			$ci++;
199 199
 		}
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 
207
-	private static function _text_link_item( $item ) {
207
+	private static function _text_link_item($item) {
208 208
 		//if this isn't an array then we're doing a separator
209
-		if ( !is_array( $item ) ) {
209
+		if ( ! is_array($item)) {
210 210
 			$label = $item;
211 211
 			$class = 'ee-text-link-sep';
212 212
 			$href = '';
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 			extract($item);
216 216
 		}
217 217
 
218
-		$class = $class != 'ee-text-link-sep'  ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"';
218
+		$class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"';
219 219
 
220
-		$content = '<li ' . $class . '>';
221
-		$content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : '';
220
+		$content = '<li '.$class.'>';
221
+		$content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : '';
222 222
 		$content .= $label;
223
-		$content .= !empty($href) ? '</a>' : '';
223
+		$content .= ! empty($href) ? '</a>' : '';
224 224
 		$content .= '</li>';
225 225
 		return $content;
226 226
 	}
Please login to merge, or discard this patch.
core/interfaces/EEI_Collection.interface.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param mixed  $info
26 26
 	 * @return bool
27 27
 	 */
28
-	public function add( $object, $info = null );
28
+	public function add($object, $info = null);
29 29
 
30 30
 
31 31
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * @param mixed  $info
40 40
 	 * @return bool
41 41
 	 */
42
-	public function set_info( $object, $info = null );
42
+	public function set_info($object, $info = null);
43 43
 
44 44
 
45 45
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 * @param mixed
53 53
 	 * @return null | object
54 54
 	 */
55
-	public function get_by_info( $info );
55
+	public function get_by_info($info);
56 56
 
57 57
 
58 58
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param object $object
66 66
 	 * @return bool
67 67
 	 */
68
-	public function has( $object );
68
+	public function has($object);
69 69
 
70 70
 
71 71
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param $object
79 79
 	 * @return void
80 80
 	 */
81
-	public function remove( $object );
81
+	public function remove($object);
82 82
 
83 83
 
84 84
 
Please login to merge, or discard this patch.
core/interfaces/EEI_Repository.interface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @return bool | int
31 31
 	 * @throws \EE_Error
32 32
 	 */
33
-	public function persist( $persistence_callback = '', $persistence_arguments = array() );
33
+	public function persist($persistence_callback = '', $persistence_arguments = array());
34 34
 
35 35
 
36 36
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $persistence_callback name of method found on object that can be used for persisting it
44 44
 	 * @return bool | int
45 45
 	 */
46
-	public function persist_all( $persistence_callback = '' );
46
+	public function persist_all($persistence_callback = '');
47 47
 
48 48
 	}
49 49
 // End of file EEI_Repository.interface.php
Please login to merge, or discard this patch.
core/interfaces/line_items/EEI_Line_Item.interface.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EEI_Line_Item
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param    mixed  $field_value
19 19
 	 * @param bool      $use_default
20 20
 	 */
21
-	public function set( $field_name, $field_value, $use_default = false );
21
+	public function set($field_name, $field_value, $use_default = false);
22 22
 
23 23
 
24 24
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * Sets quantity
57 57
 	 * @param int $quantity
58 58
 	 */
59
-	function set_quantity( $quantity );
59
+	function set_quantity($quantity);
60 60
 
61 61
 
62 62
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @param int $txn_id if none is provided, assumes $this->TXN_ID()
116 116
 	 * @return int count of items saved
117 117
 	 */
118
-	function save_this_and_descendants_to_txn( $txn_id = null );
118
+	function save_this_and_descendants_to_txn($txn_id = null);
119 119
 
120 120
 
121 121
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param bool         $set_order
143 143
 	 * @return bool true for success, false for fail
144 144
 	 */
145
-	function add_child_line_item( EEI_Line_Item $line_item, $set_order = true );
145
+	function add_child_line_item(EEI_Line_Item $line_item, $set_order = true);
146 146
 
147 147
 
148 148
 
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 	 * @param float $total
198 198
 	 * @return boolean
199 199
 	 */
200
-	function set_total( $total );
200
+	function set_total($total);
201 201
 
202 202
 	/**
203 203
 	 * Sets unit_price
204 204
 	 * @param float $unit_price
205 205
 	 * @return boolean
206 206
 	 */
207
-	function set_unit_price( $unit_price );
207
+	function set_unit_price($unit_price);
208 208
 
209 209
 	/**
210 210
 	 * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @param bool $stop_search_once_found
216 216
 	 * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet)
217 217
 	 */
218
-	function delete_child_line_item( $code, $stop_search_once_found = true );
218
+	function delete_child_line_item($code, $stop_search_once_found = true);
219 219
 
220 220
 	/**
221 221
 	 * Forgets the cached model of the given relation Name. So the next time we request it,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @param boolean $allow_persist
239 239
 	 * @return boolean
240 240
 	 */
241
-	function set_allow_persist( $allow_persist );
241
+	function set_allow_persist($allow_persist);
242 242
 
243 243
 
244 244
 }
Please login to merge, or discard this patch.
core/interfaces/line_items/EEI_Line_Item_Filter.interface.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param \EEI_Line_Item $line_item
27 27
 	 * @return \EEI_Line_Item
28 28
 	 */
29
-	public function process( EEI_Line_Item $line_item );
29
+	public function process(EEI_Line_Item $line_item);
30 30
 
31 31
 
32 32
 
Please login to merge, or discard this patch.
core/libraries/form_sections/EE_Sample_Form.form.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class EE_Sample_Form extends EE_Form_Section_Proper{
3
-	function __construct(){
2
+class EE_Sample_Form extends EE_Form_Section_Proper {
3
+	function __construct() {
4 4
 		$this->_subsections = array(
5 5
 			'h1'=>new EE_Form_Section_HTML('hello wordl'),
6
-			'name'=>new EE_Text_Input(array('required'=>true,'default'=>'your name here')),
6
+			'name'=>new EE_Text_Input(array('required'=>true, 'default'=>'your name here')),
7 7
 			'email'=>new EE_Email_Input(array('required'=>false)),
8
-			'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=>  __("Small", "event_espresso"),'m'=>  __("Medium", "event_espresso"),'l'=>  __("Large", "event_espresso")),array('required'=>true,'default'=>'s')),
8
+			'shirt_size'=>new EE_Select_Input(array(''=>'Please select...', 's'=>  __("Small", "event_espresso"), 'm'=>  __("Medium", "event_espresso"), 'l'=>  __("Large", "event_espresso")), array('required'=>true, 'default'=>'s')),
9 9
 			'month_normal'=>new EE_Month_Input(),
10 10
 			'month_leading_zero'=>new EE_Month_Input(true),
11 11
 			'year_2'=>new EE_Year_Input(false, 1, 1),
12
-			'year_4'=>new EE_Year_Input(true, 0,10,array('default'=>'2017')),
12
+			'year_4'=>new EE_Year_Input(true, 0, 10, array('default'=>'2017')),
13 13
 			'yes_no'=>new EE_Yes_No_Input(array('html_label_text'=>  __("Yes or No", "event_espresso"))),
14 14
 			'credit_card'=>new EE_Credit_Card_Input(),
15 15
 			'image_1'=>new EE_Admin_File_Uploader_Input(),
16 16
 			'image_2'=>new EE_Admin_File_Uploader_Input(),
17
-			'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP','mysql'=>'MYSQL'),array('default'=>array('php'))),
17
+			'skillz'=>new EE_Checkbox_Multi_Input(array('php'=>'PHP', 'mysql'=>'MYSQL'), array('default'=>array('php'))),
18 18
 			'float'=>new EE_Float_Input(),
19 19
 			'essay'=>new EE_Text_Area_Input(),
20 20
 			'amenities'=>new EE_Select_Multiple_Input(
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 * Extra validation for the 'name' input.
41 41
 	 * @param EE_Text_Input $form_input
42 42
 	 */
43
-	function _validate_name($form_input){
44
-		if($form_input->raw_value() != 'Mike'){
43
+	function _validate_name($form_input) {
44
+		if ($form_input->raw_value() != 'Mike') {
45 45
 			$form_input->add_validation_error(__("You are not mike. You must be brent or darren. Thats ok, I guess", 'event_espresso'), 'not-mike');
46 46
 		}
47 47
 	}
48 48
 
49
-	function _validate(){
49
+	function _validate() {
50 50
 		parent::_validate();
51
-		if($this->_subsections['shirt_size']->normalized_value() =='s'
52
-				&& $this->_subsections['year_4']->normalized_value() < 2010){
51
+		if ($this->_subsections['shirt_size']->normalized_value() == 's'
52
+				&& $this->_subsections['year_4']->normalized_value() < 2010) {
53 53
 			$this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old');
54 54
 		}
55 55
 	}
Please login to merge, or discard this patch.