@@ -44,7 +44,7 @@ |
||
44 | 44 | { |
45 | 45 | $this->model = new SplClassInfo($model); |
46 | 46 | |
47 | - if ( ! models()->has($this->model->getParameter())) { |
|
47 | + if (!models()->has($this->model->getParameter())) { |
|
48 | 48 | models()->register($this->model->getParameter(), $model); |
49 | 49 | } |
50 | 50 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @param $className |
17 | 17 | */ |
18 | 18 | spl_autoload_register( |
19 | - function ($className) { |
|
19 | + function($className) { |
|
20 | 20 | if (strpos($className, 'O2System\Reactor\\') === false) { |
21 | 21 | return; |
22 | 22 | } |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | if ($lastNsPos = strripos($className, '\\')) { |
28 | 28 | $namespace = substr($className, 0, $lastNsPos); |
29 | 29 | $className = substr($className, $lastNsPos + 1); |
30 | - $filePath = $namespace . '\\'; |
|
30 | + $filePath = $namespace.'\\'; |
|
31 | 31 | } |
32 | 32 | |
33 | - $filePath .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
|
33 | + $filePath .= str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; |
|
34 | 34 | |
35 | 35 | // Fixed Path |
36 | - $filePath = str_replace('O2System\Reactor\\', __DIR__ . DIRECTORY_SEPARATOR, $filePath); |
|
36 | + $filePath = str_replace('O2System\Reactor\\', __DIR__.DIRECTORY_SEPARATOR, $filePath); |
|
37 | 37 | $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $filePath); |
38 | 38 | |
39 | 39 | if (file_exists($filePath)) { |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | public function __construct() |
38 | 38 | { |
39 | 39 | if ($config = config()->loadFile('database', true)) { |
40 | - if ( ! empty($config[ 'default' ][ 'hostname' ]) AND ! empty($config[ 'default' ][ 'username' ])) { |
|
40 | + if (!empty($config['default']['hostname']) AND !empty($config['default']['username'])) { |
|
41 | 41 | |
42 | - if(profiler() !== false) { |
|
42 | + if (profiler() !== false) { |
|
43 | 43 | profiler()->watch('Starting Database Service'); |
44 | 44 | } |
45 | 45 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | if (isset($service) && $service instanceof SplServiceRegistry) { |
72 | 72 | if (profiler() !== false) { |
73 | - profiler()->watch('Load New Model: ' . $service->getClassName()); |
|
73 | + profiler()->watch('Load New Model: '.$service->getClassName()); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $this->register($service, $offset); |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | public function add($model, $offset = null) |
89 | 89 | { |
90 | 90 | if (is_object($service)) { |
91 | - if ( ! $service instanceof SplServiceRegistry) { |
|
91 | + if (!$service instanceof SplServiceRegistry) { |
|
92 | 92 | $service = new SplServiceRegistry($service); |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | if (profiler() !== false) { |
97 | - profiler()->watch('Add New Model: ' . $service->getClassName()); |
|
97 | + profiler()->watch('Add New Model: '.$service->getClassName()); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $this->register($service, $offset); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $this->attach($offset, $service); |
123 | 123 | |
124 | 124 | if (profiler() !== false) { |
125 | - profiler()->watch('Register New Model: ' . $service->getClassName()); |
|
125 | + profiler()->watch('Register New Model: '.$service->getClassName()); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | // ------------------------------------------------------------------------ |
18 | 18 | |
19 | -if ( ! function_exists('strip_image_tags')) { |
|
19 | +if (!function_exists('strip_image_tags')) { |
|
20 | 20 | /** |
21 | 21 | * strip_image_tags |
22 | 22 | * |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | //-------------------------------------------------------------------- |
43 | 43 | |
44 | -if ( ! function_exists('strip_cdata')) { |
|
44 | +if (!function_exists('strip_cdata')) { |
|
45 | 45 | /** |
46 | 46 | * strip_cdata |
47 | 47 | * |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | { |
56 | 56 | preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $source_code, $matches); |
57 | 57 | |
58 | - return str_replace($matches[ 0 ], $matches[ 1 ], $source_code); |
|
58 | + return str_replace($matches[0], $matches[1], $source_code); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | // ------------------------------------------------------------------------ |
62 | 62 | |
63 | -if ( ! function_exists('strips_all_tags')) { |
|
63 | +if (!function_exists('strips_all_tags')) { |
|
64 | 64 | /** |
65 | 65 | * strips_all_tags |
66 | 66 | * |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // ------------------------------------------------------------------------ |
86 | 86 | |
87 | -if ( ! function_exists('strips_tags')) { |
|
87 | +if (!function_exists('strips_tags')) { |
|
88 | 88 | /** |
89 | 89 | * strips_tags |
90 | 90 | * |
@@ -100,52 +100,52 @@ discard block |
||
100 | 100 | function strips_tags($source_code, $disallowed_tags = 'script|style|noframes|select|option', $allowed_tags = '') |
101 | 101 | { |
102 | 102 | //prep the string |
103 | - $source_code = ' ' . $source_code; |
|
103 | + $source_code = ' '.$source_code; |
|
104 | 104 | |
105 | 105 | //initialize keep tag logic |
106 | 106 | if (strlen($allowed_tags) > 0) { |
107 | 107 | $k = explode('|', $allowed_tags); |
108 | 108 | for ($i = 0; $i < count($k); $i++) { |
109 | - $source_code = str_replace('<' . $k[ $i ], '[{(' . $k[ $i ], $source_code); |
|
110 | - $source_code = str_replace('</' . $k[ $i ], '[{(/' . $k[ $i ], $source_code); |
|
109 | + $source_code = str_replace('<'.$k[$i], '[{('.$k[$i], $source_code); |
|
110 | + $source_code = str_replace('</'.$k[$i], '[{(/'.$k[$i], $source_code); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | //begin removal |
114 | 114 | //remove comment blocks |
115 | 115 | while (stripos($source_code, '<!--') > 0) { |
116 | - $pos[ 1 ] = stripos($source_code, '<!--'); |
|
117 | - $pos[ 2 ] = stripos($source_code, '-->', $pos[ 1 ]); |
|
118 | - $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 3; |
|
119 | - $x = substr($source_code, $pos[ 1 ], $len[ 1 ]); |
|
116 | + $pos[1] = stripos($source_code, '<!--'); |
|
117 | + $pos[2] = stripos($source_code, '-->', $pos[1]); |
|
118 | + $len[1] = $pos[2] - $pos[1] + 3; |
|
119 | + $x = substr($source_code, $pos[1], $len[1]); |
|
120 | 120 | $source_code = str_replace($x, '', $source_code); |
121 | 121 | } |
122 | 122 | //remove tags with content between them |
123 | 123 | if (strlen($disallowed_tags) > 0) { |
124 | 124 | $e = explode('|', $disallowed_tags); |
125 | 125 | for ($i = 0; $i < count($e); $i++) { |
126 | - while (stripos($source_code, '<' . $e[ $i ]) > 0) { |
|
127 | - $len[ 1 ] = strlen('<' . $e[ $i ]); |
|
128 | - $pos[ 1 ] = stripos($source_code, '<' . $e[ $i ]); |
|
129 | - $pos[ 2 ] = stripos($source_code, $e[ $i ] . '>', $pos[ 1 ] + $len[ 1 ]); |
|
130 | - $len[ 2 ] = $pos[ 2 ] - $pos[ 1 ] + $len[ 1 ]; |
|
131 | - $x = substr($source_code, $pos[ 1 ], $len[ 2 ]); |
|
126 | + while (stripos($source_code, '<'.$e[$i]) > 0) { |
|
127 | + $len[1] = strlen('<'.$e[$i]); |
|
128 | + $pos[1] = stripos($source_code, '<'.$e[$i]); |
|
129 | + $pos[2] = stripos($source_code, $e[$i].'>', $pos[1] + $len[1]); |
|
130 | + $len[2] = $pos[2] - $pos[1] + $len[1]; |
|
131 | + $x = substr($source_code, $pos[1], $len[2]); |
|
132 | 132 | $source_code = str_replace($x, '', $source_code); |
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | //remove remaining tags |
137 | 137 | while (stripos($source_code, '<') > 0) { |
138 | - $pos[ 1 ] = stripos($source_code, '<'); |
|
139 | - $pos[ 2 ] = stripos($source_code, '>', $pos[ 1 ]); |
|
140 | - $len[ 1 ] = $pos[ 2 ] - $pos[ 1 ] + 1; |
|
141 | - $x = substr($source_code, $pos[ 1 ], $len[ 1 ]); |
|
138 | + $pos[1] = stripos($source_code, '<'); |
|
139 | + $pos[2] = stripos($source_code, '>', $pos[1]); |
|
140 | + $len[1] = $pos[2] - $pos[1] + 1; |
|
141 | + $x = substr($source_code, $pos[1], $len[1]); |
|
142 | 142 | $source_code = str_replace($x, '', $source_code); |
143 | 143 | } |
144 | 144 | //finalize keep tag |
145 | 145 | if (strlen($allowed_tags) > 0) { |
146 | 146 | for ($i = 0; $i < count($k); $i++) { |
147 | - $source_code = str_replace('[{(' . $k[ $i ], '<' . $k[ $i ], $source_code); |
|
148 | - $source_code = str_replace('[{(/' . $k[ $i ], '</' . $k[ $i ], $source_code); |
|
147 | + $source_code = str_replace('[{('.$k[$i], '<'.$k[$i], $source_code); |
|
148 | + $source_code = str_replace('[{(/'.$k[$i], '</'.$k[$i], $source_code); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | |
156 | 156 | // ------------------------------------------------------------------------ |
157 | 157 | |
158 | -if ( ! function_exists('strip_word_doc')) { |
|
158 | +if (!function_exists('strip_word_doc')) { |
|
159 | 159 | /** |
160 | 160 | * strip_word_doc |
161 | 161 | * |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | //-------------------------------------------------------------------- |
254 | 254 | |
255 | -if ( ! function_exists('strip_slashes_recursive')) { |
|
255 | +if (!function_exists('strip_slashes_recursive')) { |
|
256 | 256 | /** |
257 | 257 | * strip_slashes_recursive |
258 | 258 | * |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | // ------------------------------------------------------------------------ |
285 | 285 | |
286 | -if ( ! function_exists('strip_comments')) { |
|
286 | +if (!function_exists('strip_comments')) { |
|
287 | 287 | /** |
288 | 288 | * strip_comments |
289 | 289 | * |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | // ------------------------------------------------------------------------ |
303 | 303 | |
304 | -if ( ! function_exists('clean_white_space')) { |
|
304 | +if (!function_exists('clean_white_space')) { |
|
305 | 305 | /** |
306 | 306 | * clean_white_space |
307 | 307 | * |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | // ------------------------------------------------------------------------ |
323 | 323 | |
324 | -if ( ! function_exists('encode_php_tags')) { |
|
324 | +if (!function_exists('encode_php_tags')) { |
|
325 | 325 | /** |
326 | 326 | * encode_php_tags |
327 | 327 | * |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | |
340 | 340 | // ------------------------------------------------------------------------ |
341 | 341 | |
342 | -if ( ! function_exists('escape_html')) { |
|
342 | +if (!function_exists('escape_html')) { |
|
343 | 343 | /** |
344 | 344 | * escape_html |
345 | 345 | * |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | // ------------------------------------------------------------------------ |
12 | 12 | |
13 | -if ( ! function_exists('timestamp')) { |
|
13 | +if (!function_exists('timestamp')) { |
|
14 | 14 | /** |
15 | 15 | * Timestamp |
16 | 16 | * |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function timestamp($timestamp = null) |
24 | 24 | { |
25 | - if ( ! isset($timestamp) OR $timestamp === 'NOW') { |
|
25 | + if (!isset($timestamp) OR $timestamp === 'NOW') { |
|
26 | 26 | $timestamp = now(); |
27 | 27 | } elseif (is_string($timestamp)) { |
28 | 28 | $timestamp = strtotime($timestamp); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | // ------------------------------------------------------------------------ |
35 | 35 | |
36 | -if ( ! function_exists('unix_timestamp')) { |
|
36 | +if (!function_exists('unix_timestamp')) { |
|
37 | 37 | /** |
38 | 38 | * Unix Timestamp |
39 | 39 | * |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function unix_timestamp($timestamp = null) |
47 | 47 | { |
48 | - if ( ! isset($timestamp) OR $timestamp === 'NOW') { |
|
48 | + if (!isset($timestamp) OR $timestamp === 'NOW') { |
|
49 | 49 | return now(); |
50 | 50 | } elseif (is_string($timestamp)) { |
51 | 51 | return strtotime($timestamp); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | // ------------------------------------------------------------------------ |
61 | 61 | |
62 | -if ( ! function_exists('format_date')) { |
|
62 | +if (!function_exists('format_date')) { |
|
63 | 63 | /** |
64 | 64 | * Day Date Time Functions |
65 | 65 | * |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $output = $format; |
92 | 92 | |
93 | 93 | foreach ($date as $replace => $value) { |
94 | - $output = str_ireplace('%' . $replace, $value, $output); |
|
94 | + $output = str_ireplace('%'.$replace, $value, $output); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | return $output; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | } |
100 | 100 | // ------------------------------------------------------------------------ |
101 | 101 | |
102 | -if ( ! function_exists('parse_date')) { |
|
102 | +if (!function_exists('parse_date')) { |
|
103 | 103 | /** |
104 | 104 | * Parse Date into Array |
105 | 105 | * |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | // ------------------------------------------------------------------------ |
155 | 155 | |
156 | -if ( ! function_exists('day_name')) { |
|
156 | +if (!function_exists('day_name')) { |
|
157 | 157 | /** |
158 | 158 | * Day Name in Languages |
159 | 159 | * |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | |
177 | 177 | language()->loadFile('calendar'); |
178 | 178 | |
179 | - return language()->getLine(strtoupper('CAL_' . date($type, $timestamp))); |
|
179 | + return language()->getLine(strtoupper('CAL_'.date($type, $timestamp))); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | // ------------------------------------------------------------------------ |
183 | 183 | |
184 | -if ( ! function_exists('month_name')) { |
|
184 | +if (!function_exists('month_name')) { |
|
185 | 185 | /** |
186 | 186 | * Month Name in Languages |
187 | 187 | * |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | ))); |
204 | 204 | language()->loadFile('calendar'); |
205 | 205 | |
206 | - return language()->getLine(strtoupper('CAL_' . date($type, $timestamp))); |
|
206 | + return language()->getLine(strtoupper('CAL_'.date($type, $timestamp))); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | // ------------------------------------------------------------------------ |
210 | 210 | |
211 | -if ( ! function_exists('part_time')) { |
|
211 | +if (!function_exists('part_time')) { |
|
212 | 212 | /** |
213 | 213 | * Part Time in Languages |
214 | 214 | * |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | } |
255 | 255 | // ------------------------------------------------------------------------ |
256 | 256 | |
257 | -if ( ! function_exists('string_time_elapsed')) { |
|
257 | +if (!function_exists('string_time_elapsed')) { |
|
258 | 258 | /** |
259 | 259 | * Day Date Time in String Format |
260 | 260 | * |
@@ -292,25 +292,25 @@ discard block |
||
292 | 292 | |
293 | 293 | foreach ($string as $key => &$value) { |
294 | 294 | if ($diff->$key) { |
295 | - $value = $diff->$key . ' ' . $value . ($diff->$key > 1 && language()->getDefaultLocale() === 'en' ? 's' : ''); |
|
295 | + $value = $diff->$key.' '.$value.($diff->$key > 1 && language()->getDefaultLocale() === 'en' ? 's' : ''); |
|
296 | 296 | } else { |
297 | - unset($string[ $key ]); |
|
297 | + unset($string[$key]); |
|
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - if ( ! $full) { |
|
301 | + if (!$full) { |
|
302 | 302 | $string = array_slice($string, 0, 1); |
303 | 303 | } |
304 | 304 | |
305 | 305 | return $string ? implode(', ', |
306 | - $string) . ' ' . language()->getLine('DATE_AGO') : language()->getLine('DATE_JUST_NOW'); |
|
306 | + $string).' '.language()->getLine('DATE_AGO') : language()->getLine('DATE_JUST_NOW'); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | } |
310 | 310 | |
311 | 311 | // ------------------------------------------------------------------------ |
312 | 312 | |
313 | -if ( ! function_exists('dates_between')) { |
|
313 | +if (!function_exists('dates_between')) { |
|
314 | 314 | /** |
315 | 315 | * Date Between |
316 | 316 | * |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | function dates_between($start_date, $end_date, $format = 'Y-m-d') |
328 | 328 | { |
329 | 329 | $day = 60 * 60 * 24; |
330 | - $start_date = (! is_numeric($start_date) ? strtotime($start_date) : $start_date); |
|
331 | - $end_date = (! is_numeric($end_date) ? strtotime($end_date) : $end_date); |
|
330 | + $start_date = (!is_numeric($start_date) ? strtotime($start_date) : $start_date); |
|
331 | + $end_date = (!is_numeric($end_date) ? strtotime($end_date) : $end_date); |
|
332 | 332 | |
333 | 333 | $days_diff = round( |
334 | 334 | ($end_date - $start_date) / $day |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | |
363 | 363 | // ------------------------------------------------------------------------ |
364 | 364 | |
365 | -if ( ! function_exists('time_range')) { |
|
365 | +if (!function_exists('time_range')) { |
|
366 | 366 | /** |
367 | 367 | * Time Range List |
368 | 368 | * |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | $time = []; |
379 | 379 | $minutes = range(0, (60 - $step), $step); |
380 | 380 | for ($i = 0; $i <= 23; $i++) { |
381 | - $hour = (strlen($i) == 1 ? '0' . $i : $i); |
|
381 | + $hour = (strlen($i) == 1 ? '0'.$i : $i); |
|
382 | 382 | foreach ($minutes as $minute) { |
383 | - $hours = $hour . ':' . (strlen($minute) == 1 ? '0' . $minute : $minute); |
|
383 | + $hours = $hour.':'.(strlen($minute) == 1 ? '0'.$minute : $minute); |
|
384 | 384 | $time_12 = date("h:i a", strtotime($hours)); |
385 | 385 | $time_24 = $hours; |
386 | 386 | if ($mode == 12) { |
387 | - $time[ $time_12 ] = $time_12; |
|
387 | + $time[$time_12] = $time_12; |
|
388 | 388 | } elseif ($mode == 24) { |
389 | - $time[ $time_24 ] = $time_24; |
|
389 | + $time[$time_24] = $time_24; |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
@@ -397,7 +397,7 @@ discard block |
||
397 | 397 | |
398 | 398 | // ------------------------------------------------------------------------ |
399 | 399 | |
400 | -if ( ! function_exists('calculate_days')) { |
|
400 | +if (!function_exists('calculate_days')) { |
|
401 | 401 | /** |
402 | 402 | * calculate_days |
403 | 403 | * |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | $end_date = (is_numeric($end_date) ? date('d-m-Y', $end_date) : $end_date); |
416 | 416 | $hour = (is_numeric($hour) ? date('h:i:s a', $hour) : $hour); |
417 | 417 | |
418 | - $start_date = $start_date . ' ' . $hour; |
|
419 | - $end_date = $end_date . ' ' . $hour; |
|
418 | + $start_date = $start_date.' '.$hour; |
|
419 | + $end_date = $end_date.' '.$hour; |
|
420 | 420 | |
421 | 421 | $start_date = strtotime($start_date); |
422 | 422 | $end_date = strtotime($end_date); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | } |
430 | 430 | // ------------------------------------------------------------------------ |
431 | 431 | |
432 | -if ( ! function_exists('calculate_weeks')) { |
|
432 | +if (!function_exists('calculate_weeks')) { |
|
433 | 433 | /** |
434 | 434 | * calculate_weeks |
435 | 435 | * |
@@ -447,8 +447,8 @@ discard block |
||
447 | 447 | $end_date = (is_numeric($end_date) ? date('d-m-Y', $end_date) : $end_date); |
448 | 448 | $hour = (is_numeric($hour) ? date('h:i:s a', $hour) : $hour); |
449 | 449 | |
450 | - $start_date = $start_date . ' ' . $hour; |
|
451 | - $end_date = $end_date . ' ' . $hour; |
|
450 | + $start_date = $start_date.' '.$hour; |
|
451 | + $end_date = $end_date.' '.$hour; |
|
452 | 452 | |
453 | 453 | $start_date = strtotime($start_date); |
454 | 454 | $end_date = strtotime($end_date); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | } |
462 | 462 | // ------------------------------------------------------------------------ |
463 | 463 | |
464 | -if ( ! function_exists('is_weekend')) { |
|
464 | +if (!function_exists('is_weekend')) { |
|
465 | 465 | /** |
466 | 466 | * Is Weekend |
467 | 467 | * |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | */ |
474 | 474 | function is_weekend($date) |
475 | 475 | { |
476 | - $date = (! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
476 | + $date = (!is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
477 | 477 | $date = date('D', $date); |
478 | 478 | |
479 | 479 | if ($date == 'Sat' OR $date == 'Sun') { |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | } |
486 | 486 | // ------------------------------------------------------------------------ |
487 | 487 | |
488 | -if ( ! function_exists('is_weekday')) { |
|
488 | +if (!function_exists('is_weekday')) { |
|
489 | 489 | /** |
490 | 490 | * Is Week Day |
491 | 491 | * |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | */ |
498 | 498 | function is_weekday($date) |
499 | 499 | { |
500 | - $date = (! is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
500 | + $date = (!is_numeric($date) ? strtotime(str_replace('/', '-', $date)) : $date); |
|
501 | 501 | $date = date('D', $date); |
502 | 502 | |
503 | - if ( ! in_array($date, ['Sat', 'Sun'])) { |
|
503 | + if (!in_array($date, ['Sat', 'Sun'])) { |
|
504 | 504 | return true; |
505 | 505 | } |
506 | 506 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | } |
510 | 510 | // ------------------------------------------------------------------------ |
511 | 511 | |
512 | -if ( ! function_exists('get_age')) { |
|
512 | +if (!function_exists('get_age')) { |
|
513 | 513 | /** |
514 | 514 | * Get Age |
515 | 515 | * |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | */ |
523 | 523 | function get_age($birthday, $return = 'years') |
524 | 524 | { |
525 | - $birthday = (! is_numeric($birthday) ? strtotime(str_replace('/', '-', $birthday)) : $birthday); |
|
525 | + $birthday = (!is_numeric($birthday) ? strtotime(str_replace('/', '-', $birthday)) : $birthday); |
|
526 | 526 | |
527 | 527 | $birthday = new DateTime(date('Y-m-d', $birthday)); |
528 | 528 | $now = new DateTime(date('Y-m-d')); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | ]; |
538 | 538 | |
539 | 539 | if (array_key_exists($return, $available)) { |
540 | - return $interval->{$available[ $return ]}; |
|
540 | + return $interval->{$available[$return]}; |
|
541 | 541 | } elseif (isset($interval->{$return})) { |
542 | 542 | return $interval->{$return}; |
543 | 543 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | } |
548 | 548 | // ------------------------------------------------------------------------ |
549 | 549 | |
550 | -if ( ! function_exists('get_tenure')) { |
|
550 | +if (!function_exists('get_tenure')) { |
|
551 | 551 | /** |
552 | 552 | * get_tenure |
553 | 553 | * |
@@ -573,15 +573,15 @@ discard block |
||
573 | 573 | $dateInterval = $date_start->diff($date_end); |
574 | 574 | |
575 | 575 | return strtolower($dateInterval->format( |
576 | - '%y ' . language()->getLine('DATE_YEARS') . |
|
577 | - ' — %m ' . language()->getLine('DATE_MONTHS') . |
|
578 | - ' — %d ' . language()->getLine('DATE_DAYS'))); |
|
576 | + '%y '.language()->getLine('DATE_YEARS'). |
|
577 | + ' — %m '.language()->getLine('DATE_MONTHS'). |
|
578 | + ' — %d '.language()->getLine('DATE_DAYS'))); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
582 | 582 | // ------------------------------------------------------------------------ |
583 | 583 | |
584 | -if ( ! function_exists('time_breakdown')) { |
|
584 | +if (!function_exists('time_breakdown')) { |
|
585 | 585 | /** |
586 | 586 | * Time Breakdown |
587 | 587 | * |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | */ |
594 | 594 | function time_breakdown($time) |
595 | 595 | { |
596 | - if ( ! is_numeric($time)) { |
|
596 | + if (!is_numeric($time)) { |
|
597 | 597 | $time = strtotime($time); |
598 | 598 | } |
599 | 599 | $currentTime = time(); |
@@ -622,8 +622,8 @@ discard block |
||
622 | 622 | } |
623 | 623 | foreach ($periods as $period => $seconds_in_period) { |
624 | 624 | if ($seconds >= $seconds_in_period) { |
625 | - $durations[ $period ] = floor($seconds / $seconds_in_period); |
|
626 | - $seconds -= $durations[ $period ] * $seconds_in_period; |
|
625 | + $durations[$period] = floor($seconds / $seconds_in_period); |
|
626 | + $seconds -= $durations[$period] * $seconds_in_period; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | } |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | } |
634 | 634 | // ------------------------------------------------------------------------ |
635 | 635 | |
636 | -if ( ! function_exists('sec2hms')) { |
|
636 | +if (!function_exists('sec2hms')) { |
|
637 | 637 | /** |
638 | 638 | * Second to Miliseconds |
639 | 639 | * |
@@ -645,12 +645,12 @@ discard block |
||
645 | 645 | { |
646 | 646 | $str = ''; |
647 | 647 | $hours = intval(intval($num_secs) / 3600); |
648 | - $str .= $hours . ':'; |
|
648 | + $str .= $hours.':'; |
|
649 | 649 | $minutes = intval(((intval($num_secs) / 60) % 60)); |
650 | 650 | if ($minutes < 10) { |
651 | 651 | $str .= '0'; |
652 | 652 | } |
653 | - $str .= $minutes . ':'; |
|
653 | + $str .= $minutes.':'; |
|
654 | 654 | $seconds = intval(intval(($num_secs % 60))); |
655 | 655 | if ($seconds < 10) { |
656 | 656 | $str .= '0'; |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } |
663 | 663 | // ------------------------------------------------------------------------ |
664 | 664 | |
665 | -if ( ! function_exists('add_time_duration')) { |
|
665 | +if (!function_exists('add_time_duration')) { |
|
666 | 666 | /** |
667 | 667 | * Add Time Duration |
668 | 668 | * |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | */ |
675 | 675 | function add_time_duration($start_time, $duration, $return = 'time') |
676 | 676 | { |
677 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
677 | + $start_time = (!is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
678 | 678 | $duration = $duration * 60 * 60; // (x) hours * 60 minutes * 60 seconds |
679 | 679 | |
680 | 680 | $add_time = $start_time + $duration; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | } |
689 | 689 | // ------------------------------------------------------------------------ |
690 | 690 | |
691 | -if ( ! function_exists('calculate_hours')) { |
|
691 | +if (!function_exists('calculate_hours')) { |
|
692 | 692 | /** |
693 | 693 | * Calculate Hours |
694 | 694 | * |
@@ -700,8 +700,8 @@ discard block |
||
700 | 700 | */ |
701 | 701 | function calculate_hours($start_time, $end_time, $return = 'time') |
702 | 702 | { |
703 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
704 | - $end_time = (! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
703 | + $start_time = (!is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
704 | + $end_time = (!is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
705 | 705 | |
706 | 706 | // Times Difference |
707 | 707 | $difference = $end_time - $start_time; |
@@ -719,10 +719,10 @@ discard block |
||
719 | 719 | $final_minutes = round($minutes); |
720 | 720 | |
721 | 721 | if ($return === 'time') { |
722 | - $final_hours = ($final_hours < 10 ? '0' . $final_hours : $final_hours); |
|
723 | - $final_minutes = ($final_minutes < 10 ? '0' . $final_minutes : $final_minutes); |
|
722 | + $final_hours = ($final_hours < 10 ? '0'.$final_hours : $final_hours); |
|
723 | + $final_minutes = ($final_minutes < 10 ? '0'.$final_minutes : $final_minutes); |
|
724 | 724 | |
725 | - return $final_hours . ':' . $final_minutes; |
|
725 | + return $final_hours.':'.$final_minutes; |
|
726 | 726 | } elseif ($return === 'hours') { |
727 | 727 | return $final_hours + ($final_minutes / 60); |
728 | 728 | } |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | } |
731 | 731 | // ------------------------------------------------------------------------ |
732 | 732 | |
733 | -if ( ! function_exists('time_difference')) { |
|
733 | +if (!function_exists('time_difference')) { |
|
734 | 734 | /** |
735 | 735 | * Time Difference |
736 | 736 | * |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | */ |
743 | 743 | function time_difference($start_time, $end_time, $return = 'array') |
744 | 744 | { |
745 | - $start_time = (! is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
746 | - $end_time = (! is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
745 | + $start_time = (!is_numeric($start_time) ? strtotime($start_time) : $start_time); |
|
746 | + $end_time = (!is_numeric($end_time) ? strtotime($end_time) : $end_time); |
|
747 | 747 | |
748 | 748 | // Times Difference |
749 | 749 | $difference = $end_time - $start_time; |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | } |
759 | 759 | // ------------------------------------------------------------------------ |
760 | 760 | |
761 | -if ( ! function_exists('weeks_in_month')) { |
|
761 | +if (!function_exists('weeks_in_month')) { |
|
762 | 762 | /** |
763 | 763 | * @param null $month |
764 | 764 | * @param null $year |
@@ -769,13 +769,13 @@ discard block |
||
769 | 769 | { |
770 | 770 | // Start Date in Month |
771 | 771 | $start_date_month = mktime(0, 0, 0, $month, 1, $year); |
772 | - $start_week_month = (int)date('W', $start_date_month); |
|
772 | + $start_week_month = (int) date('W', $start_date_month); |
|
773 | 773 | |
774 | 774 | $amount_day = days_in_month($month, $year); |
775 | 775 | |
776 | 776 | // Finish Date in onth |
777 | 777 | $finish_date_month = mktime(0, 0, 0, $month, $amount_day, $year); |
778 | - $finish_week_month = (int)date('W', $finish_date_month); |
|
778 | + $finish_week_month = (int) date('W', $finish_date_month); |
|
779 | 779 | |
780 | 780 | $amount_week = $finish_week_month - $start_week_month + 1; |
781 | 781 | |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | } |
785 | 785 | // ------------------------------------------------------------------------ |
786 | 786 | |
787 | -if ( ! function_exists('monday_of_week')) { |
|
787 | +if (!function_exists('monday_of_week')) { |
|
788 | 788 | /** |
789 | 789 | * Monday of Week |
790 | 790 | * |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | // ------------------------------------------------------------------------ |
811 | 811 | |
812 | -if ( ! function_exists('week_number_of_month')) { |
|
812 | +if (!function_exists('week_number_of_month')) { |
|
813 | 813 | /** |
814 | 814 | * Week Number of Month |
815 | 815 | * |
@@ -826,11 +826,11 @@ discard block |
||
826 | 826 | |
827 | 827 | // Start Date in Month |
828 | 828 | $start_date_month = mktime(0, 0, 0, $month, 1, $year); |
829 | - $start_week_month = (int)date('W', $start_date_month); |
|
829 | + $start_week_month = (int) date('W', $start_date_month); |
|
830 | 830 | |
831 | 831 | // Date Search |
832 | 832 | $date_search = mktime(0, 0, 0, $month, $date, $year); |
833 | - $date_week_search = (int)date('W', $date_search); |
|
833 | + $date_week_search = (int) date('W', $date_search); |
|
834 | 834 | |
835 | 835 | $number_of_week = $date_week_search - $start_week_month + 1; |
836 | 836 | |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | } |
840 | 840 | // ------------------------------------------------------------------------ |
841 | 841 | |
842 | -if ( ! function_exists('format_time')) { |
|
842 | +if (!function_exists('format_time')) { |
|
843 | 843 | /** |
844 | 844 | * Format Time from seconds |
845 | 845 | * |
@@ -868,12 +868,12 @@ discard block |
||
868 | 868 | $seconds -= $minutes * 60; |
869 | 869 | } |
870 | 870 | |
871 | - $format[ 'days' ] = $days; |
|
872 | - $format[ 'years' ] = $years; |
|
873 | - $format[ 'months' ] = $months; |
|
874 | - $format[ 'hours' ] = $hours; |
|
875 | - $format[ 'minutes' ] = $minutes; |
|
876 | - $format[ 'seconds' ] = $seconds; |
|
871 | + $format['days'] = $days; |
|
872 | + $format['years'] = $years; |
|
873 | + $format['months'] = $months; |
|
874 | + $format['hours'] = $hours; |
|
875 | + $format['minutes'] = $minutes; |
|
876 | + $format['seconds'] = $seconds; |
|
877 | 877 | |
878 | 878 | return new \O2System\Spl\Datastructures\SplArrayObject($format); |
879 | 879 | } |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | |
929 | 929 | // ------------------------------------------------------------------------ |
930 | 930 | |
931 | -if ( ! function_exists('now')) { |
|
931 | +if (!function_exists('now')) { |
|
932 | 932 | /** |
933 | 933 | * now |
934 | 934 | * |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | |
961 | 961 | // ------------------------------------------------------------------------ |
962 | 962 | |
963 | -if ( ! function_exists('mdate')) { |
|
963 | +if (!function_exists('mdate')) { |
|
964 | 964 | /** |
965 | 965 | * Convert MySQL Style Datecodes |
966 | 966 | * |
@@ -998,7 +998,7 @@ discard block |
||
998 | 998 | |
999 | 999 | // ------------------------------------------------------------------------ |
1000 | 1000 | |
1001 | -if ( ! function_exists('standard_date')) { |
|
1001 | +if (!function_exists('standard_date')) { |
|
1002 | 1002 | /** |
1003 | 1003 | * Standard Date |
1004 | 1004 | * |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | |
1037 | 1037 | // ------------------------------------------------------------------------ |
1038 | 1038 | |
1039 | -if ( ! function_exists('timespan')) { |
|
1039 | +if (!function_exists('timespan')) { |
|
1040 | 1040 | /** |
1041 | 1041 | * Timespan |
1042 | 1042 | * |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | $years = floor($seconds / 31557600); |
1064 | 1064 | |
1065 | 1065 | if ($years > 0) { |
1066 | - $str[] = $years . ' ' . language()->getLine($years > 1 ? 'DATE_YEARS' : 'DATE_YEAR'); |
|
1066 | + $str[] = $years.' '.language()->getLine($years > 1 ? 'DATE_YEARS' : 'DATE_YEAR'); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $seconds -= $years * 31557600; |
@@ -1071,7 +1071,7 @@ discard block |
||
1071 | 1071 | |
1072 | 1072 | if (count($str) < $units && ($years > 0 OR $months > 0)) { |
1073 | 1073 | if ($months > 0) { |
1074 | - $str[] = $months . ' ' . language()->getLine($months > 1 ? 'DATE_MONTHS' : 'DATE_MONTH'); |
|
1074 | + $str[] = $months.' '.language()->getLine($months > 1 ? 'DATE_MONTHS' : 'DATE_MONTH'); |
|
1075 | 1075 | } |
1076 | 1076 | |
1077 | 1077 | $seconds -= $months * 2629743; |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | |
1082 | 1082 | if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0)) { |
1083 | 1083 | if ($weeks > 0) { |
1084 | - $str[] = $weeks . ' ' . language()->getLine($weeks > 1 ? 'DATE_WEEKS' : 'DATE_WEEK'); |
|
1084 | + $str[] = $weeks.' '.language()->getLine($weeks > 1 ? 'DATE_WEEKS' : 'DATE_WEEK'); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | $seconds -= $weeks * 604800; |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0)) { |
1093 | 1093 | if ($days > 0) { |
1094 | - $str[] = $days . ' ' . language()->getLine($days > 1 ? 'DATE_DAYS' : 'DATE_DAY'); |
|
1094 | + $str[] = $days.' '.language()->getLine($days > 1 ? 'DATE_DAYS' : 'DATE_DAY'); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | $seconds -= $days * 86400; |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | |
1102 | 1102 | if (count($str) < $units && ($days > 0 OR $hours > 0)) { |
1103 | 1103 | if ($hours > 0) { |
1104 | - $str[] = $hours . ' ' . language()->getLine($hours > 1 ? 'DATE_HOURS' : 'DATE_HOUR'); |
|
1104 | + $str[] = $hours.' '.language()->getLine($hours > 1 ? 'DATE_HOURS' : 'DATE_HOUR'); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | $seconds -= $hours * 3600; |
@@ -1111,14 +1111,14 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0)) { |
1113 | 1113 | if ($minutes > 0) { |
1114 | - $str[] = $minutes . ' ' . language()->getLine($minutes > 1 ? 'DATE_MINUTES' : 'DATE_MINUTE'); |
|
1114 | + $str[] = $minutes.' '.language()->getLine($minutes > 1 ? 'DATE_MINUTES' : 'DATE_MINUTE'); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | $seconds -= $minutes * 60; |
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | if (count($str) === 0) { |
1121 | - $str[] = $seconds . ' ' . language()->getLine($seconds > 1 ? 'DATE_SECONDS' : 'DATE_SECOND'); |
|
1121 | + $str[] = $seconds.' '.language()->getLine($seconds > 1 ? 'DATE_SECONDS' : 'DATE_SECOND'); |
|
1122 | 1122 | } |
1123 | 1123 | |
1124 | 1124 | return implode(', ', $str); |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | |
1128 | 1128 | // ------------------------------------------------------------------------ |
1129 | 1129 | |
1130 | -if ( ! function_exists('days_in_month')) { |
|
1130 | +if (!function_exists('days_in_month')) { |
|
1131 | 1131 | /** |
1132 | 1132 | * Number of days in a month |
1133 | 1133 | * |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | { |
1144 | 1144 | if ($month < 1 OR $month > 12) { |
1145 | 1145 | return 0; |
1146 | - } elseif ( ! is_numeric($year) OR strlen($year) !== 4) { |
|
1146 | + } elseif (!is_numeric($year) OR strlen($year) !== 4) { |
|
1147 | 1147 | $year = date('Y'); |
1148 | 1148 | } |
1149 | 1149 | |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | } |
1153 | 1153 | |
1154 | 1154 | if ($year >= 1970) { |
1155 | - return (int)date('t', mktime(12, 0, 0, $month, 1, $year)); |
|
1155 | + return (int) date('t', mktime(12, 0, 0, $month, 1, $year)); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | if ($month == 2) { |
@@ -1163,13 +1163,13 @@ discard block |
||
1163 | 1163 | |
1164 | 1164 | $days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; |
1165 | 1165 | |
1166 | - return $days_in_month[ $month - 1 ]; |
|
1166 | + return $days_in_month[$month - 1]; |
|
1167 | 1167 | } |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | // ------------------------------------------------------------------------ |
1171 | 1171 | |
1172 | -if ( ! function_exists('local_to_gmt')) { |
|
1172 | +if (!function_exists('local_to_gmt')) { |
|
1173 | 1173 | /** |
1174 | 1174 | * Converts a local Unix timestamp to GMT |
1175 | 1175 | * |
@@ -1196,7 +1196,7 @@ discard block |
||
1196 | 1196 | |
1197 | 1197 | // ------------------------------------------------------------------------ |
1198 | 1198 | |
1199 | -if ( ! function_exists('gmt_to_local')) { |
|
1199 | +if (!function_exists('gmt_to_local')) { |
|
1200 | 1200 | /** |
1201 | 1201 | * Converts GMT time to a localized value |
1202 | 1202 | * |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | |
1225 | 1225 | // ------------------------------------------------------------------------ |
1226 | 1226 | |
1227 | -if ( ! function_exists('mysql_to_unix')) { |
|
1227 | +if (!function_exists('mysql_to_unix')) { |
|
1228 | 1228 | /** |
1229 | 1229 | * Converts a MySQL Timestamp to Unix |
1230 | 1230 | * |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | |
1255 | 1255 | // ------------------------------------------------------------------------ |
1256 | 1256 | |
1257 | -if ( ! function_exists('unix_to_human')) { |
|
1257 | +if (!function_exists('unix_to_human')) { |
|
1258 | 1258 | /** |
1259 | 1259 | * Unix to "Human" |
1260 | 1260 | * |
@@ -1268,20 +1268,20 @@ discard block |
||
1268 | 1268 | */ |
1269 | 1269 | function unix_to_human($time = '', $seconds = false, $fmt = 'us') |
1270 | 1270 | { |
1271 | - $r = date('Y', $time) . '-' . date('m', $time) . '-' . date('d', $time) . ' '; |
|
1271 | + $r = date('Y', $time).'-'.date('m', $time).'-'.date('d', $time).' '; |
|
1272 | 1272 | |
1273 | 1273 | if ($fmt === 'us') { |
1274 | - $r .= date('h', $time) . ':' . date('i', $time); |
|
1274 | + $r .= date('h', $time).':'.date('i', $time); |
|
1275 | 1275 | } else { |
1276 | - $r .= date('H', $time) . ':' . date('i', $time); |
|
1276 | + $r .= date('H', $time).':'.date('i', $time); |
|
1277 | 1277 | } |
1278 | 1278 | |
1279 | 1279 | if ($seconds) { |
1280 | - $r .= ':' . date('s', $time); |
|
1280 | + $r .= ':'.date('s', $time); |
|
1281 | 1281 | } |
1282 | 1282 | |
1283 | 1283 | if ($fmt === 'us') { |
1284 | - return $r . ' ' . date('A', $time); |
|
1284 | + return $r.' '.date('A', $time); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | return $r; |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | |
1291 | 1291 | // ------------------------------------------------------------------------ |
1292 | 1292 | |
1293 | -if ( ! function_exists('human_to_unix')) { |
|
1293 | +if (!function_exists('human_to_unix')) { |
|
1294 | 1294 | /** |
1295 | 1295 | * Convert "human" date to GMT |
1296 | 1296 | * |
@@ -1308,7 +1308,7 @@ discard block |
||
1308 | 1308 | |
1309 | 1309 | $date = preg_replace('/\040+/', ' ', trim($date)); |
1310 | 1310 | |
1311 | - if ( ! preg_match( |
|
1311 | + if (!preg_match( |
|
1312 | 1312 | '/^(\d{2}|\d{4})\-[0-9]{1,2}\-[0-9]{1,2}\s[0-9]{1,2}:[0-9]{1,2}(?::[0-9]{1,2})?(?:\s[AP]M)?$/i', |
1313 | 1313 | $date |
1314 | 1314 | ) |
@@ -1323,9 +1323,9 @@ discard block |
||
1323 | 1323 | if (isset($ampm)) { |
1324 | 1324 | $ampm = strtolower($ampm); |
1325 | 1325 | |
1326 | - if ($ampm[ 0 ] === 'p' && $hour < 12) { |
|
1326 | + if ($ampm[0] === 'p' && $hour < 12) { |
|
1327 | 1327 | $hour += 12; |
1328 | - } elseif ($ampm[ 0 ] === 'a' && $hour === 12) { |
|
1328 | + } elseif ($ampm[0] === 'a' && $hour === 12) { |
|
1329 | 1329 | $hour = 0; |
1330 | 1330 | } |
1331 | 1331 | } |
@@ -1336,7 +1336,7 @@ discard block |
||
1336 | 1336 | |
1337 | 1337 | // ------------------------------------------------------------------------ |
1338 | 1338 | |
1339 | -if ( ! function_exists('nice_date')) { |
|
1339 | +if (!function_exists('nice_date')) { |
|
1340 | 1340 | /** |
1341 | 1341 | * Turns many "reasonably-date-like" strings into something |
1342 | 1342 | * that is actually useful. This only works for dates after unix epoch. |
@@ -1364,17 +1364,17 @@ discard block |
||
1364 | 1364 | $year = substr($bad_date, 2, 4); |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - return date($format, strtotime($year . '-' . $month . '-01')); |
|
1367 | + return date($format, strtotime($year.'-'.$month.'-01')); |
|
1368 | 1368 | } |
1369 | 1369 | |
1370 | 1370 | // Date Like: YYYYMMDD |
1371 | 1371 | if (preg_match('/^(\d{2})\d{2}(\d{4})$/i', $bad_date, $matches)) { |
1372 | - return date($format, strtotime($matches[ 1 ] . '/01/' . $matches[ 2 ])); |
|
1372 | + return date($format, strtotime($matches[1].'/01/'.$matches[2])); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | // Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between) |
1376 | 1376 | if (preg_match('/^(\d{1,2})-(\d{1,2})-(\d{4})$/i', $bad_date, $matches)) { |
1377 | - return date($format, strtotime($matches[ 3 ] . '-' . $matches[ 1 ] . '-' . $matches[ 2 ])); |
|
1377 | + return date($format, strtotime($matches[3].'-'.$matches[1].'-'.$matches[2])); |
|
1378 | 1378 | } |
1379 | 1379 | |
1380 | 1380 | // Any other kind of string, when converted into UNIX time, |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | |
1392 | 1392 | // ------------------------------------------------------------------------ |
1393 | 1393 | |
1394 | -if ( ! function_exists('timezones')) { |
|
1394 | +if (!function_exists('timezones')) { |
|
1395 | 1395 | /** |
1396 | 1396 | * Timezones |
1397 | 1397 | * |
@@ -1454,13 +1454,13 @@ discard block |
||
1454 | 1454 | return $zones; |
1455 | 1455 | } |
1456 | 1456 | |
1457 | - return isset($zones[ $tz ]) ? $zones[ $tz ] : 0; |
|
1457 | + return isset($zones[$tz]) ? $zones[$tz] : 0; |
|
1458 | 1458 | } |
1459 | 1459 | } |
1460 | 1460 | |
1461 | 1461 | // ------------------------------------------------------------------------ |
1462 | 1462 | |
1463 | -if ( ! function_exists('date_range_unix')) { |
|
1463 | +if (!function_exists('date_range_unix')) { |
|
1464 | 1464 | /** |
1465 | 1465 | * Date range |
1466 | 1466 | * |
@@ -1483,11 +1483,11 @@ discard block |
||
1483 | 1483 | return false; |
1484 | 1484 | } |
1485 | 1485 | |
1486 | - $is_unix = ! ( ! $is_unix OR $is_unix === 'days'); |
|
1486 | + $is_unix = !(!$is_unix OR $is_unix === 'days'); |
|
1487 | 1487 | |
1488 | 1488 | // Validate input and try strtotime() on invalid timestamps/intervals, just in case |
1489 | - if (( ! ctype_digit((string)$unix_start) && ($unix_start = @strtotime($unix_start)) === false) |
|
1490 | - OR ( ! ctype_digit((string)$mixed) && ($is_unix === false OR ($mixed = @strtotime( |
|
1489 | + if ((!ctype_digit((string) $unix_start) && ($unix_start = @strtotime($unix_start)) === false) |
|
1490 | + OR (!ctype_digit((string) $mixed) && ($is_unix === false OR ($mixed = @strtotime( |
|
1491 | 1491 | $mixed |
1492 | 1492 | )) === false)) |
1493 | 1493 | OR ($is_unix === true && $mixed < $unix_start) |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | $arg = new DateTime(); |
1526 | 1526 | $arg->setTimestamp($mixed); |
1527 | 1527 | } else { |
1528 | - $arg = (int)$mixed; |
|
1528 | + $arg = (int) $mixed; |
|
1529 | 1529 | } |
1530 | 1530 | |
1531 | 1531 | $period = new DatePeriod($from, new DateInterval('P1D'), $arg); |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | * the end date might actually be less than 24 hours away from the previously |
1539 | 1539 | * generated DateTime object, but either way - we have to append it manually. |
1540 | 1540 | */ |
1541 | - if ( ! is_int($arg) && $range[ count($range) - 1 ] !== $arg->format($format)) { |
|
1541 | + if (!is_int($arg) && $range[count($range) - 1] !== $arg->format($format)) { |
|
1542 | 1542 | $range[] = $arg->format($format); |
1543 | 1543 | } |
1544 | 1544 | |
@@ -1552,7 +1552,7 @@ discard block |
||
1552 | 1552 | $arg->setDate(date('Y', $mixed), date('n', $mixed), date('j', $mixed)); |
1553 | 1553 | $arg->setTime(date('G', $mixed), date('i', $mixed), date('s', $mixed)); |
1554 | 1554 | } else { |
1555 | - $arg = (int)$mixed; |
|
1555 | + $arg = (int) $mixed; |
|
1556 | 1556 | } |
1557 | 1557 | $range[] = $from->format($format); |
1558 | 1558 |
@@ -1556,10 +1556,12 @@ |
||
1556 | 1556 | } |
1557 | 1557 | $range[] = $from->format($format); |
1558 | 1558 | |
1559 | - if (is_int($arg)) // Day intervals |
|
1559 | + if (is_int($arg)) { |
|
1560 | + // Day intervals |
|
1560 | 1561 | { |
1561 | 1562 | do { |
1562 | 1563 | $from->modify('+1 day'); |
1564 | + } |
|
1563 | 1565 | $range[] = $from->format($format); |
1564 | 1566 | } while (--$arg > 0); |
1565 | 1567 | } else // end date UNIX timestamp |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | // ------------------------------------------------------------------------ |
18 | 18 | |
19 | -if ( ! function_exists('is_positive')) { |
|
19 | +if (!function_exists('is_positive')) { |
|
20 | 20 | /** |
21 | 21 | * is_positive |
22 | 22 | * |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | } |
38 | 38 | // ------------------------------------------------------------------------ |
39 | 39 | |
40 | -if ( ! function_exists('is_negative')) { |
|
40 | +if (!function_exists('is_negative')) { |
|
41 | 41 | /** |
42 | 42 | * is_negative |
43 | 43 | * |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | // ------------------------------------------------------------------------ |
60 | 60 | |
61 | -if ( ! function_exists('is_odd')) { |
|
61 | +if (!function_exists('is_odd')) { |
|
62 | 62 | /** |
63 | 63 | * is_odd |
64 | 64 | * |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | // ------------------------------------------------------------------------ |
81 | 81 | |
82 | -if ( ! function_exists('is_even')) { |
|
82 | +if (!function_exists('is_even')) { |
|
83 | 83 | /** |
84 | 84 | * is_even |
85 | 85 | * |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | // ------------------------------------------------------------------------ |
102 | 102 | |
103 | -if ( ! function_exists('currency_format')) { |
|
103 | +if (!function_exists('currency_format')) { |
|
104 | 104 | /** |
105 | 105 | * currency_format |
106 | 106 | * |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | // ------------------------------------------------------------------------ |
128 | 128 | |
129 | -if ( ! function_exists('unit_format')) { |
|
129 | +if (!function_exists('unit_format')) { |
|
130 | 130 | /** |
131 | 131 | * unit format |
132 | 132 | * |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $number = number_format($number, $decimals, $decimal_point, $thousands_separator); |
146 | 146 | |
147 | 147 | if (isset($unit)) { |
148 | - return $number . ' ' . $unit; |
|
148 | + return $number.' '.$unit; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $number; |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | // ------------------------------------------------------------------------ |
155 | 155 | |
156 | -if ( ! function_exists('hertz_format')) { |
|
156 | +if (!function_exists('hertz_format')) { |
|
157 | 157 | /** |
158 | 158 | * hertz_format |
159 | 159 | * |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | } else { |
182 | 182 | $unit = 'Hz'; |
183 | 183 | |
184 | - return number_format($number) . ' ' . $unit; |
|
184 | + return number_format($number).' '.$unit; |
|
185 | 185 | } |
186 | 186 | |
187 | - return number_format($number, $decimals) . ' ' . $unit; |
|
187 | + return number_format($number, $decimals).' '.$unit; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | |
191 | 191 | // ------------------------------------------------------------------------ |
192 | 192 | |
193 | -if ( ! function_exists('roman_format')) { |
|
193 | +if (!function_exists('roman_format')) { |
|
194 | 194 | /** |
195 | 195 | * roman_format |
196 | 196 | * |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // ------------------------------------------------------------------------ |
238 | 238 | |
239 | -if ( ! function_exists('short_format')) { |
|
239 | +if (!function_exists('short_format')) { |
|
240 | 240 | /** |
241 | 241 | * short_format |
242 | 242 | * |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | // We found a match! |
267 | 267 | // We found our match, or there were no matches. |
268 | 268 | // Either way, use the last defined value for $divisor. |
269 | - return number_format($number / $divisor, $decimals) . $shorthand; |
|
269 | + return number_format($number / $divisor, $decimals).$shorthand; |
|
270 | 270 | break; |
271 | 271 | } |
272 | 272 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | // ------------------------------------------------------------------------ |
277 | 277 | |
278 | -if ( ! function_exists('byte_format')) { |
|
278 | +if (!function_exists('byte_format')) { |
|
279 | 279 | /** |
280 | 280 | * byte_format |
281 | 281 | * |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | } else { |
306 | 306 | $unit = language()->getLine('BYTES'); |
307 | 307 | |
308 | - return number_format($number) . ' ' . $unit; |
|
308 | + return number_format($number).' '.$unit; |
|
309 | 309 | } |
310 | 310 | |
311 | - return number_format($number, $decimals) . ' ' . $unit; |
|
311 | + return number_format($number, $decimals).' '.$unit; |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | // ------------------------------------------------------------------------ |
316 | 316 | |
317 | -if ( ! function_exists('ordinal_format')) { |
|
317 | +if (!function_exists('ordinal_format')) { |
|
318 | 318 | /** |
319 | 319 | * ordinal_format |
320 | 320 | * |
@@ -340,15 +340,15 @@ discard block |
||
340 | 340 | 'th', |
341 | 341 | ]; |
342 | 342 | |
343 | - return $number . ($number % 100 >= 11 && $number % 100 <= 13 |
|
343 | + return $number.($number % 100 >= 11 && $number % 100 <= 13 |
|
344 | 344 | ? 'th' |
345 | - : $suffixes[ $number % 10 ]); |
|
345 | + : $suffixes[$number % 10]); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | 349 | // ------------------------------------------------------------------------ |
350 | 350 | |
351 | -if ( ! function_exists('words_format')) { |
|
351 | +if (!function_exists('words_format')) { |
|
352 | 352 | /** |
353 | 353 | * words_format |
354 | 354 | * |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | |
370 | 370 | // ------------------------------------------------------------------------ |
371 | 371 | |
372 | -if ( ! function_exists('zero_fill')) { |
|
372 | +if (!function_exists('zero_fill')) { |
|
373 | 373 | /** |
374 | 374 | * zero_fill |
375 | 375 | * |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | // ------------------------------------------------------------------------ |
389 | 389 | |
390 | -if ( ! function_exists('calculate')) { |
|
390 | +if (!function_exists('calculate')) { |
|
391 | 391 | /** |
392 | 392 | * Calculate |
393 | 393 | * |
@@ -435,15 +435,15 @@ discard block |
||
435 | 435 | // Illegal function |
436 | 436 | $formula = preg_replace_callback( |
437 | 437 | '~\b[a-z]\w*\b~', |
438 | - function ($match) use ($function_map) { |
|
439 | - $function = $match[ 0 ]; |
|
440 | - if ( ! isset($function_map[ $function ])) { |
|
438 | + function($match) use ($function_map) { |
|
439 | + $function = $match[0]; |
|
440 | + if (!isset($function_map[$function])) { |
|
441 | 441 | trigger_error("Illegal function '{$match[0]}'", E_USER_ERROR); |
442 | 442 | |
443 | 443 | return ''; |
444 | 444 | } |
445 | 445 | |
446 | - return $function_map[ $function ]; |
|
446 | + return $function_map[$function]; |
|
447 | 447 | }, |
448 | 448 | $formula |
449 | 449 | ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | // ------------------------------------------------------------------------ |
12 | 12 | |
13 | -if ( ! function_exists('text_split')) { |
|
13 | +if (!function_exists('text_split')) { |
|
14 | 14 | /** |
15 | 15 | * text_split |
16 | 16 | * |
@@ -27,14 +27,14 @@ discard block |
||
27 | 27 | function text_split($text, $splitter = '<---text-split--->', $limit = 100) |
28 | 28 | { |
29 | 29 | $wrap_text = wordwrap($text, $limit, $splitter); |
30 | - $wrap_text = preg_split('[' . $splitter . ']', $wrap_text, -1, PREG_SPLIT_NO_EMPTY); |
|
30 | + $wrap_text = preg_split('['.$splitter.']', $wrap_text, -1, PREG_SPLIT_NO_EMPTY); |
|
31 | 31 | |
32 | 32 | return implode('', $wrap_text); |
33 | 33 | } |
34 | 34 | } |
35 | 35 | // ------------------------------------------------------------------------ |
36 | 36 | |
37 | -if ( ! function_exists('text_columns')) { |
|
37 | +if (!function_exists('text_columns')) { |
|
38 | 38 | /** |
39 | 39 | * text_columns |
40 | 40 | * |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | $return = explode("\n", wordwrap(strrev($text), $col_length)); |
52 | 52 | |
53 | 53 | if (count($return) > $cols) { |
54 | - $return[ $cols - 1 ] .= " " . $return[ $cols ]; |
|
55 | - unset($return[ $cols ]); |
|
54 | + $return[$cols - 1] .= " ".$return[$cols]; |
|
55 | + unset($return[$cols]); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | $return = array_map("strrev", $return); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | } |
63 | 63 | // ------------------------------------------------------------------------ |
64 | 64 | |
65 | -if ( ! function_exists('text_wrap')) { |
|
65 | +if (!function_exists('text_wrap')) { |
|
66 | 66 | /** |
67 | 67 | * text_wrap |
68 | 68 | * |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | function text_wrap($text, $chars = 10, $lines = false) |
78 | 78 | { |
79 | 79 | # the simple case - return wrapped words |
80 | - if ( ! $lines) { |
|
80 | + if (!$lines) { |
|
81 | 81 | return wordwrap($text, $chars, "\n"); |
82 | 82 | } |
83 | 83 | # truncate to maximum possible number of characters |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | $return = wordwrap($return, $chars, "\n"); |
87 | 87 | preg_match("/(.+\n?){0,$lines}/", $return, $regs); |
88 | 88 | |
89 | - return $regs[ 0 ]; |
|
89 | + return $regs[0]; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | // ------------------------------------------------------------------------ |
93 | 93 | |
94 | -if ( ! function_exists('text_trim')) { |
|
94 | +if (!function_exists('text_trim')) { |
|
95 | 95 | /** |
96 | 96 | * Cuts the given string to a certain length without breaking a word. |
97 | 97 | * |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | // is $break present between $limit and the end of the string? |
112 | 112 | if (false !== ($breakpoint = strpos($text, $break, $limit))) { |
113 | 113 | if ($breakpoint < strlen($text) - 1) { |
114 | - $text = substr($text, 0, $breakpoint) . $ending; |
|
114 | + $text = substr($text, 0, $breakpoint).$ending; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | // ------------------------------------------------------------------------ |
123 | 123 | |
124 | -if ( ! function_exists('text_word_limiter')) { |
|
124 | +if (!function_exists('text_word_limiter')) { |
|
125 | 125 | /** |
126 | 126 | * text_word_limiter |
127 | 127 | * |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | return $str; |
140 | 140 | } |
141 | 141 | |
142 | - preg_match('/^\s*+(?:\S++\s*+){1,' . (int)$limit . '}/', $str, $matches); |
|
142 | + preg_match('/^\s*+(?:\S++\s*+){1,'.(int) $limit.'}/', $str, $matches); |
|
143 | 143 | |
144 | - if (strlen($str) === strlen($matches[ 0 ])) { |
|
144 | + if (strlen($str) === strlen($matches[0])) { |
|
145 | 145 | $end_char = ''; |
146 | 146 | } |
147 | 147 | |
148 | - return rtrim($matches[ 0 ]) . $end_char; |
|
148 | + return rtrim($matches[0]).$end_char; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | 152 | // ------------------------------------------------------------------------ |
153 | 153 | |
154 | -if ( ! function_exists('text_character_limiter')) { |
|
154 | +if (!function_exists('text_character_limiter')) { |
|
155 | 155 | /** |
156 | 156 | * text_character_limiter |
157 | 157 | * |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | |
180 | 180 | $out = ''; |
181 | 181 | foreach (explode(' ', trim($string)) as $val) { |
182 | - $out .= $val . ' '; |
|
182 | + $out .= $val.' '; |
|
183 | 183 | |
184 | 184 | if (mb_strlen($out) >= $n) { |
185 | 185 | $out = trim($out); |
186 | 186 | |
187 | - return (mb_strlen($out) === mb_strlen($string)) ? $out : $out . $end_char; |
|
187 | + return (mb_strlen($out) === mb_strlen($string)) ? $out : $out.$end_char; |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | // ------------------------------------------------------------------------ |
194 | 194 | |
195 | -if ( ! function_exists('text_censored')) { |
|
195 | +if (!function_exists('text_censored')) { |
|
196 | 196 | /** |
197 | 197 | * text_censored |
198 | 198 | * |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function text_censored($string, $censored, $replacement = '') |
210 | 210 | { |
211 | - if ( ! is_array($censored)) { |
|
211 | + if (!is_array($censored)) { |
|
212 | 212 | return $string; |
213 | 213 | } |
214 | 214 | |
215 | - $string = ' ' . $string . ' '; |
|
215 | + $string = ' '.$string.' '; |
|
216 | 216 | |
217 | 217 | // \w, \b and a few others do not match on a unicode character |
218 | 218 | // set for performance reasons. As a result words like �ber |
@@ -223,13 +223,13 @@ discard block |
||
223 | 223 | foreach ($censored as $badword) { |
224 | 224 | if ($replacement !== '') { |
225 | 225 | $string = preg_replace( |
226 | - "/({$delim})(" . str_replace('\*', '\w*?', preg_quote($badword, '/')) . ")({$delim})/i", |
|
226 | + "/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/i", |
|
227 | 227 | "\\1{$replacement}\\3", |
228 | 228 | $string |
229 | 229 | ); |
230 | 230 | } else { |
231 | 231 | $string = preg_replace( |
232 | - "/({$delim})(" . str_replace('\*', '\w*?', preg_quote($badword, '/')) . ")({$delim})/ie", |
|
232 | + "/({$delim})(".str_replace('\*', '\w*?', preg_quote($badword, '/')).")({$delim})/ie", |
|
233 | 233 | "'\\1'.str_repeat('#', strlen('\\2')).'\\3'", |
234 | 234 | $string |
235 | 235 | ); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | |
243 | 243 | // ------------------------------------------------------------------------ |
244 | 244 | |
245 | -if ( ! function_exists('text_highlight_phrase')) { |
|
245 | +if (!function_exists('text_highlight_phrase')) { |
|
246 | 246 | /** |
247 | 247 | * text_highlight_phrase |
248 | 248 | * |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | { |
260 | 260 | return ($string !== '' && $phrase !== '') |
261 | 261 | ? preg_replace( |
262 | - '/(' . preg_quote($phrase, '/') . ')/i' . ('UTF8_ENABLED' ? 'u' : ''), |
|
263 | - $tag_open . '\\1' . $tag_close, |
|
262 | + '/('.preg_quote($phrase, '/').')/i'.('UTF8_ENABLED' ? 'u' : ''), |
|
263 | + $tag_open.'\\1'.$tag_close, |
|
264 | 264 | $string |
265 | 265 | ) |
266 | 266 | : $string; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | // ------------------------------------------------------------------------ |
271 | 271 | |
272 | -if ( ! function_exists('text_word_wrap')) { |
|
272 | +if (!function_exists('text_word_wrap')) { |
|
273 | 273 | /** |
274 | 274 | * text_word_wrap |
275 | 275 | * |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | // strip the entire chunk and replace it with a marker. |
300 | 300 | $unwrap = []; |
301 | 301 | if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $string, $matches)) { |
302 | - for ($i = 0, $c = count($matches[ 0 ]); $i < $c; $i++) { |
|
303 | - $unwrap[] = $matches[ 1 ][ $i ]; |
|
304 | - $string = str_replace($matches[ 0 ][ $i ], '{{unwrapped' . $i . '}}', $string); |
|
302 | + for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { |
|
303 | + $unwrap[] = $matches[1][$i]; |
|
304 | + $string = str_replace($matches[0][$i], '{{unwrapped'.$i.'}}', $string); |
|
305 | 305 | } |
306 | 306 | } |
307 | 307 | |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | // Is the line within the allowed character count? |
317 | 317 | // If so we'll join it to the output and continue |
318 | 318 | if (mb_strlen($line) <= $limit) { |
319 | - $output .= $line . "\n"; |
|
319 | + $output .= $line."\n"; |
|
320 | 320 | continue; |
321 | 321 | } |
322 | 322 | |
@@ -335,16 +335,16 @@ discard block |
||
335 | 335 | // If $temp contains data it means we had to split up an over-length |
336 | 336 | // word into smaller chunks so we'll add it back to our current line |
337 | 337 | if ($temp !== '') { |
338 | - $output .= $temp . "\n" . $line . "\n"; |
|
338 | + $output .= $temp."\n".$line."\n"; |
|
339 | 339 | } else { |
340 | - $output .= $line . "\n"; |
|
340 | + $output .= $line."\n"; |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | 344 | // Put our markers back |
345 | 345 | if (count($unwrap) > 0) { |
346 | 346 | foreach ($unwrap as $key => $val) { |
347 | - $output = str_replace('{{unwrapped' . $key . '}}', $val, $output); |
|
347 | + $output = str_replace('{{unwrapped'.$key.'}}', $val, $output); |
|
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | // ------------------------------------------------------------------------ |
356 | 356 | |
357 | -if ( ! function_exists('text_ellipsis')) { |
|
357 | +if (!function_exists('text_ellipsis')) { |
|
358 | 358 | /** |
359 | 359 | * text_ellipsis |
360 | 360 | * |
@@ -386,13 +386,13 @@ discard block |
||
386 | 386 | $end = mb_substr($string, -($max_length - mb_strlen($beg))); |
387 | 387 | } |
388 | 388 | |
389 | - return $beg . $ellipsis . $end; |
|
389 | + return $beg.$ellipsis.$end; |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | |
393 | 393 | // ------------------------------------------------------------------------ |
394 | 394 | |
395 | -if ( ! function_exists('text_excerpt')) { |
|
395 | +if (!function_exists('text_excerpt')) { |
|
396 | 396 | /** |
397 | 397 | * text_excerpt |
398 | 398 | * |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if (isset($phrase)) { |
414 | 414 | $phrase_pos = strpos(strtolower($string), strtolower($phrase)); |
415 | 415 | $phrase_len = strlen($phrase); |
416 | - } elseif ( ! isset($phrase)) { |
|
416 | + } elseif (!isset($phrase)) { |
|
417 | 417 | $phrase_pos = $radius / 2; |
418 | 418 | $phrase_len = 1; |
419 | 419 | } |
@@ -424,19 +424,19 @@ discard block |
||
424 | 424 | $count = 0; |
425 | 425 | foreach (array_reverse($pre) as $pr => $e) { |
426 | 426 | if ((strlen($e) + $count + 1) < $radius) { |
427 | - $prev = ' ' . $e . $prev; |
|
427 | + $prev = ' '.$e.$prev; |
|
428 | 428 | } |
429 | 429 | $count = ++$count + strlen($e); |
430 | 430 | } |
431 | 431 | $count = 0; |
432 | 432 | foreach ($pos as $po => $s) { |
433 | 433 | if ((strlen($s) + $count + 1) < $radius) { |
434 | - $post .= $s . ' '; |
|
434 | + $post .= $s.' '; |
|
435 | 435 | } |
436 | 436 | $count = ++$count + strlen($s); |
437 | 437 | } |
438 | 438 | $ellPre = $phrase ? $ellipsis : ''; |
439 | 439 | |
440 | - return $ellPre . $prev . $phrase . $post . $ellipsis; |
|
440 | + return $ellPre.$prev.$phrase.$post.$ellipsis; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | \ No newline at end of file |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * A collection of helper function to work with array. |
16 | 16 | */ |
17 | 17 | // ------------------------------------------------------------------------ |
18 | -if ( ! function_exists('array_get_value')) { |
|
18 | +if (!function_exists('array_get_value')) { |
|
19 | 19 | /** |
20 | 20 | * array_get_value |
21 | 21 | * |
@@ -30,13 +30,13 @@ discard block |
||
30 | 30 | */ |
31 | 31 | function array_get_value($key, array $array, $default = null) |
32 | 32 | { |
33 | - return array_key_exists($key, $array) ? $array[ $key ] : $default; |
|
33 | + return array_key_exists($key, $array) ? $array[$key] : $default; |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | // ------------------------------------------------------------------------ |
38 | 38 | |
39 | -if ( ! function_exists('array_get_values')) { |
|
39 | +if (!function_exists('array_get_values')) { |
|
40 | 40 | /** |
41 | 41 | * array_get_values |
42 | 42 | * |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | |
58 | 58 | foreach ($keys as $item) { |
59 | 59 | if (array_key_exists($item, $array)) { |
60 | - $return[ $item ] = $array[ $item ]; |
|
60 | + $return[$item] = $array[$item]; |
|
61 | 61 | } elseif (is_array($default) && array_key_exists($item, $default)) { |
62 | - $return[ $item ] = $default[ $item ]; |
|
63 | - } elseif ( ! empty($default)) { |
|
64 | - $return[ $item ] = $default; |
|
62 | + $return[$item] = $default[$item]; |
|
63 | + } elseif (!empty($default)) { |
|
64 | + $return[$item] = $default; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | // ------------------------------------------------------------------------ |
74 | 74 | |
75 | -if ( ! function_exists('array_combines')) { |
|
75 | +if (!function_exists('array_combines')) { |
|
76 | 76 | /** |
77 | 77 | * array_combines |
78 | 78 | * |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | $combine_array = []; |
89 | 89 | |
90 | 90 | foreach ($keys as $index => $key) { |
91 | - $combine_array[ $key ][] = $values[ $index ]; |
|
91 | + $combine_array[$key][] = $values[$index]; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | array_walk( |
95 | 95 | $combine_array, |
96 | - function (&$value) { |
|
96 | + function(&$value) { |
|
97 | 97 | $value = (count($value) == 1) ? array_pop($value) : $value; |
98 | 98 | } |
99 | 99 | ); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | // ------------------------------------------------------------------------ |
106 | 106 | |
107 | -if ( ! function_exists('array_group')) { |
|
107 | +if (!function_exists('array_group')) { |
|
108 | 108 | /** |
109 | 109 | * array_group |
110 | 110 | * |
@@ -122,18 +122,18 @@ discard block |
||
122 | 122 | if ($flip) { |
123 | 123 | array_walk_recursive( |
124 | 124 | $array, |
125 | - function ($value, $key) use (&$group_array) { |
|
126 | - if ( ! isset($group_array[ $value ]) || ! is_array($group_array[ $value ])) { |
|
127 | - $group_array[ $value ] = []; |
|
125 | + function($value, $key) use (&$group_array) { |
|
126 | + if (!isset($group_array[$value]) || !is_array($group_array[$value])) { |
|
127 | + $group_array[$value] = []; |
|
128 | 128 | } |
129 | - $group_array[ $value ][] = $key; |
|
129 | + $group_array[$value][] = $key; |
|
130 | 130 | } |
131 | 131 | ); |
132 | 132 | } else { |
133 | 133 | array_walk_recursive( |
134 | 134 | $array, |
135 | - function ($value, $key) use (&$group_array) { |
|
136 | - $group_array[ $key ][] = $value; |
|
135 | + function($value, $key) use (&$group_array) { |
|
136 | + $group_array[$key][] = $value; |
|
137 | 137 | } |
138 | 138 | ); |
139 | 139 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | } |
144 | 144 | |
145 | -if ( ! function_exists('array_filter_recursive')) { |
|
145 | +if (!function_exists('array_filter_recursive')) { |
|
146 | 146 | /** |
147 | 147 | * array_filter_recursive |
148 | 148 | * |
@@ -171,16 +171,16 @@ discard block |
||
171 | 171 | if ($count > 0 and $count == $limit) { |
172 | 172 | return $result; |
173 | 173 | } |
174 | - if ( ! is_array($value)) { |
|
174 | + if (!is_array($value)) { |
|
175 | 175 | if ($key != $value) { |
176 | - $result[ $key ] = $value; |
|
176 | + $result[$key] = $value; |
|
177 | 177 | $count++; |
178 | 178 | } |
179 | 179 | } else { |
180 | 180 | $sub = array_filter_recursive($value, $value, $limit); |
181 | 181 | if (count($sub) > 0) { |
182 | 182 | if ($key != $value) { |
183 | - $result[ $key ] = $sub; |
|
183 | + $result[$key] = $sub; |
|
184 | 184 | $count += count($sub); |
185 | 185 | } |
186 | 186 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | // ------------------------------------------------------------------------ |
195 | 195 | |
196 | -if ( ! function_exists('array_search_recursive')) { |
|
196 | +if (!function_exists('array_search_recursive')) { |
|
197 | 197 | /** |
198 | 198 | * array_search_recursive |
199 | 199 | * |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | if ($strict === false) { |
213 | 213 | $needle = strtolower($needle); |
214 | 214 | |
215 | - if ( ! is_array($value)) { |
|
215 | + if (!is_array($value)) { |
|
216 | 216 | $value = strtolower($value); |
217 | 217 | } else { |
218 | 218 | $value = array_map('strtolower', $value); |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | |
237 | 237 | // ------------------------------------------------------------------------ |
238 | 238 | |
239 | -if ( ! function_exists('array_unique_recursive')) { |
|
239 | +if (!function_exists('array_unique_recursive')) { |
|
240 | 240 | /** |
241 | 241 | * array_unique_recursive |
242 | 242 | * |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | // ------------------------------------------------------------------------ |
259 | 259 | |
260 | -if ( ! function_exists('array_flatten')) { |
|
260 | +if (!function_exists('array_flatten')) { |
|
261 | 261 | /** |
262 | 262 | * array_flatten |
263 | 263 | * |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | if (is_array($value)) { |
276 | 276 | $flat_array = array_merge($flat_array, array_flatten($value)); |
277 | 277 | } else { |
278 | - $flat_array[ $key ] = $value; |
|
278 | + $flat_array[$key] = $value; |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | |
286 | 286 | // ------------------------------------------------------------------------ |
287 | 287 | |
288 | -if ( ! function_exists('range_price')) { |
|
288 | +if (!function_exists('range_price')) { |
|
289 | 289 | /** |
290 | 290 | * range_price |
291 | 291 | * |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | |
315 | 315 | $prices = []; |
316 | 316 | for ($i = 0; $i < count($ranges); $i++) { |
317 | - if ($ranges[ $i ] == $max) { |
|
317 | + if ($ranges[$i] == $max) { |
|
318 | 318 | break; |
319 | 319 | } else { |
320 | - $prices[ $ranges[ $i ] ] = ($ranges[ $i + 1 ] == 0) ? $ranges[ $i ] * 2 : $ranges[ $i + 1 ]; |
|
320 | + $prices[$ranges[$i]] = ($ranges[$i + 1] == 0) ? $ranges[$i] * 2 : $ranges[$i + 1]; |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | // ------------------------------------------------------------------------ |
329 | 329 | |
330 | 330 | |
331 | -if ( ! function_exists('range_date')) { |
|
331 | +if (!function_exists('range_date')) { |
|
332 | 332 | /** |
333 | 333 | * range_date |
334 | 334 | * |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | |
346 | 346 | $date_range = []; |
347 | 347 | for ($i = 0; $i < $days; $i++) { |
348 | - $date_range[ $i ] = $start_date + ($i * 24 * 60 * 60); |
|
348 | + $date_range[$i] = $start_date + ($i * 24 * 60 * 60); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | return $date_range; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | // ------------------------------------------------------------------------ |
355 | 355 | |
356 | -if ( ! function_exists('range_year')) { |
|
356 | +if (!function_exists('range_year')) { |
|
357 | 357 | /** |
358 | 358 | * range_year |
359 | 359 | * |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $years = []; |
373 | 373 | |
374 | 374 | foreach (range($min, $max, $step) as $year) { |
375 | - $years[ $year ] = $year; |
|
375 | + $years[$year] = $year; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | return $years; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | // ------------------------------------------------------------------------ |
12 | 12 | |
13 | -if ( ! function_exists('str_echo')) { |
|
13 | +if (!function_exists('str_echo')) { |
|
14 | 14 | /** |
15 | 15 | * str_echo |
16 | 16 | * |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function str_echo($string, $prefix = null, $suffix = null, $glue = '') |
27 | 27 | { |
28 | - if ( ! empty($string) OR $string !== '') { |
|
28 | + if (!empty($string) OR $string !== '') { |
|
29 | 29 | return implode($glue, array_filter([ |
30 | 30 | $prefix, |
31 | 31 | $string, |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | // ------------------------------------------------------------------------ |
41 | 41 | |
42 | -if ( ! function_exists('str_email')) { |
|
42 | +if (!function_exists('str_email')) { |
|
43 | 43 | /** |
44 | 44 | * str_email |
45 | 45 | * |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function str_email($string) |
53 | 53 | { |
54 | - if ( ! empty($string) or $string != '') { |
|
54 | + if (!empty($string) or $string != '') { |
|
55 | 55 | return str_replace( |
56 | 56 | [ |
57 | 57 | '.', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | // ------------------------------------------------------------------------ |
73 | 73 | |
74 | -if ( ! function_exists('str_alphanumeric')) { |
|
74 | +if (!function_exists('str_alphanumeric')) { |
|
75 | 75 | /** |
76 | 76 | * str_alphanumeric |
77 | 77 | * |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function str_alphanumeric($string) |
86 | 86 | { |
87 | - if ( ! empty($string) or $string != '') { |
|
87 | + if (!empty($string) or $string != '') { |
|
88 | 88 | $string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string); |
89 | 89 | } |
90 | 90 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | // ------------------------------------------------------------------------ |
96 | 96 | |
97 | -if ( ! function_exists('str_numeric')) { |
|
97 | +if (!function_exists('str_numeric')) { |
|
98 | 98 | /** |
99 | 99 | * str_numeric |
100 | 100 | * |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function str_numeric($string) |
111 | 111 | { |
112 | - if ( ! empty($string) or $string != '') { |
|
112 | + if (!empty($string) or $string != '') { |
|
113 | 113 | $string = preg_replace("/[^0-9\s]/", "", $string); |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | // ------------------------------------------------------------------------ |
121 | 121 | |
122 | -if ( ! function_exists('str_truncate')) { |
|
122 | +if (!function_exists('str_truncate')) { |
|
123 | 123 | /** |
124 | 124 | * str_truncate |
125 | 125 | * |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $string = strip_tags($string); |
138 | 138 | $string = substr($string, 0, $limit); |
139 | 139 | $string = substr($string, 0, -(strlen(strrchr($string, ' ')))); |
140 | - $string = $string . $ending; |
|
140 | + $string = $string.$ending; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $string; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | // ------------------------------------------------------------------------ |
148 | 148 | |
149 | -if ( ! function_exists('str_shorten')) { |
|
149 | +if (!function_exists('str_shorten')) { |
|
150 | 150 | /** |
151 | 151 | * str_shorten |
152 | 152 | * |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | if (strlen($string) > $limit) { |
164 | 164 | $prefix = substr($string, 0, ($limit / 2)); |
165 | 165 | $suffix = substr($string, -($limit / 2)); |
166 | - $string = $prefix . ' ... ' . $suffix; |
|
166 | + $string = $prefix.' ... '.$suffix; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | return $string; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | // ------------------------------------------------------------------------ |
174 | 174 | |
175 | -if ( ! function_exists('str_obfuscate')) { |
|
175 | +if (!function_exists('str_obfuscate')) { |
|
176 | 176 | /** |
177 | 177 | * str_obfuscate |
178 | 178 | * |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $length = strlen($string); |
188 | 188 | $scrambled = ''; |
189 | 189 | for ($i = 0; $i < $length; ++$i) { |
190 | - $scrambled .= '&#' . ord(substr($string, $i, 1)) . ';'; |
|
190 | + $scrambled .= '&#'.ord(substr($string, $i, 1)).';'; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | return $scrambled; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | // ------------------------------------------------------------------------ |
198 | 198 | |
199 | -if ( ! function_exists('str_symbol_to_entities')) { |
|
199 | +if (!function_exists('str_symbol_to_entities')) { |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * str_symbol_to_entities |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | |
465 | 465 | // ------------------------------------------------------------------------ |
466 | 466 | |
467 | -if ( ! function_exists('str_strip_slashes')) { |
|
467 | +if (!function_exists('str_strip_slashes')) { |
|
468 | 468 | /** |
469 | 469 | * str_strip_slashes |
470 | 470 | * |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | */ |
477 | 477 | function str_strip_slashes($string) |
478 | 478 | { |
479 | - if ( ! is_array($string)) { |
|
479 | + if (!is_array($string)) { |
|
480 | 480 | return stripslashes($string); |
481 | 481 | } |
482 | 482 | |
483 | 483 | foreach ($string as $key => $val) { |
484 | - $string[ $key ] = str_strip_slashes($val); |
|
484 | + $string[$key] = str_strip_slashes($val); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | return $string; |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | |
491 | 491 | // ------------------------------------------------------------------------ |
492 | 492 | |
493 | -if ( ! function_exists('str_quote_strip')) { |
|
493 | +if (!function_exists('str_quote_strip')) { |
|
494 | 494 | /** |
495 | 495 | * str_quote_strip |
496 | 496 | * |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | |
509 | 509 | // ------------------------------------------------------------------------ |
510 | 510 | |
511 | -if ( ! function_exists('str_quote_to_entities')) { |
|
511 | +if (!function_exists('str_quote_to_entities')) { |
|
512 | 512 | /** |
513 | 513 | * str_quote_to_entities |
514 | 514 | * |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | // ------------------------------------------------------------------------ |
528 | 528 | |
529 | 529 | |
530 | -if ( ! function_exists('str_filter_char')) { |
|
530 | +if (!function_exists('str_filter_char')) { |
|
531 | 531 | /** |
532 | 532 | * str_filter_char |
533 | 533 | * |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | */ |
548 | 548 | function str_filter_char($str, $character = ',', $trim = false) |
549 | 549 | { |
550 | - $str = preg_replace('#' . preg_quote($character, '#') . '{2,}#', $character, $str); |
|
550 | + $str = preg_replace('#'.preg_quote($character, '#').'{2,}#', $character, $str); |
|
551 | 551 | |
552 | 552 | return ($trim === true) ? trim($str, $character) : $str; |
553 | 553 | } |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | // ------------------------------------------------------------------------ |
557 | 557 | |
558 | -if ( ! function_exists('str_rand')) { |
|
558 | +if (!function_exists('str_rand')) { |
|
559 | 559 | /** |
560 | 560 | * str_rand |
561 | 561 | * |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | |
605 | 605 | // ------------------------------------------------------------------------ |
606 | 606 | |
607 | -if ( ! function_exists('str_inc')) { |
|
607 | +if (!function_exists('str_inc')) { |
|
608 | 608 | /** |
609 | 609 | * str_inc |
610 | 610 | * |
@@ -618,15 +618,15 @@ discard block |
||
618 | 618 | */ |
619 | 619 | function str_inc($string, $separator = '_', $first = 1) |
620 | 620 | { |
621 | - preg_match('/(.+)' . $separator . '([0-9]+)$/', $string, $match); |
|
621 | + preg_match('/(.+)'.$separator.'([0-9]+)$/', $string, $match); |
|
622 | 622 | |
623 | - return isset($match[ 2 ]) ? $match[ 1 ] . $separator . ($match[ 2 ] + 1) : $string . $separator . $first; |
|
623 | + return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $string.$separator.$first; |
|
624 | 624 | } |
625 | 625 | } |
626 | 626 | |
627 | 627 | // ------------------------------------------------------------------------ |
628 | 628 | |
629 | -if ( ! function_exists('str_alt')) { |
|
629 | +if (!function_exists('str_alt')) { |
|
630 | 630 | /** |
631 | 631 | * str_alt |
632 | 632 | * |
@@ -648,11 +648,11 @@ discard block |
||
648 | 648 | |
649 | 649 | $args = func_get_args(); |
650 | 650 | |
651 | - return $args[ ($i++ % count($args)) ]; |
|
651 | + return $args[($i++ % count($args))]; |
|
652 | 652 | } |
653 | 653 | } |
654 | 654 | |
655 | -if ( ! function_exists('str_char_to_ascii')) { |
|
655 | +if (!function_exists('str_char_to_ascii')) { |
|
656 | 656 | /** |
657 | 657 | * str_char_to_ascii |
658 | 658 | * |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | { |
667 | 667 | static $array_from, $array_to; |
668 | 668 | |
669 | - if ( ! is_array($array_from)) { |
|
669 | + if (!is_array($array_from)) { |
|
670 | 670 | $foreign_characters = [ |
671 | 671 | '/ä|æ|ǽ/' => 'ae', |
672 | 672 | '/ö|œ/' => 'oe', |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | // ------------------------------------------------------------------------ |
771 | 771 | |
772 | 772 | |
773 | -if ( ! function_exists('str_entities_to_ascii')) { |
|
773 | +if (!function_exists('str_entities_to_ascii')) { |
|
774 | 774 | /** |
775 | 775 | * str_entities_to_ascii |
776 | 776 | * |
@@ -784,22 +784,22 @@ discard block |
||
784 | 784 | function str_entities_to_ascii($string, $all = true) |
785 | 785 | { |
786 | 786 | if (preg_match_all('/\&#(\d+)\;/', $string, $matches)) { |
787 | - for ($i = 0, $s = count($matches[ 0 ]); $i < $s; $i++) { |
|
788 | - $digits = $matches[ 1 ][ $i ]; |
|
787 | + for ($i = 0, $s = count($matches[0]); $i < $s; $i++) { |
|
788 | + $digits = $matches[1][$i]; |
|
789 | 789 | $out = ''; |
790 | 790 | |
791 | 791 | if ($digits < 128) { |
792 | 792 | $out .= chr($digits); |
793 | 793 | |
794 | 794 | } elseif ($digits < 2048) { |
795 | - $out .= chr(192 + (($digits - ($digits % 64)) / 64)) . chr(128 + ($digits % 64)); |
|
795 | + $out .= chr(192 + (($digits - ($digits % 64)) / 64)).chr(128 + ($digits % 64)); |
|
796 | 796 | } else { |
797 | 797 | $out .= chr(224 + (($digits - ($digits % 4096)) / 4096)) |
798 | 798 | . chr(128 + ((($digits % 4096) - ($digits % 64)) / 64)) |
799 | 799 | . chr(128 + ($digits % 64)); |
800 | 800 | } |
801 | 801 | |
802 | - $string = str_replace($matches[ 0 ][ $i ], $out, $string); |
|
802 | + $string = str_replace($matches[0][$i], $out, $string); |
|
803 | 803 | } |
804 | 804 | } |
805 | 805 | |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | // ------------------------------------------------------------------------ |
819 | 819 | |
820 | 820 | |
821 | -if ( ! function_exists('str_ascii_to_entities')) { |
|
821 | +if (!function_exists('str_ascii_to_entities')) { |
|
822 | 822 | /** |
823 | 823 | * str_ascii_to_entities |
824 | 824 | * |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | { |
833 | 833 | $out = ''; |
834 | 834 | for ($i = 0, $s = strlen($string) - 1, $count = 1, $temp = []; $i <= $s; $i++) { |
835 | - $ordinal = ord($string[ $i ]); |
|
835 | + $ordinal = ord($string[$i]); |
|
836 | 836 | |
837 | 837 | if ($ordinal < 128) { |
838 | 838 | /* |
@@ -840,11 +840,11 @@ discard block |
||
840 | 840 | fair that we output that entity and restart $temp before continuing. -Paul |
841 | 841 | */ |
842 | 842 | if (count($temp) === 1) { |
843 | - $out .= '&#' . array_shift($temp) . ';'; |
|
843 | + $out .= '&#'.array_shift($temp).';'; |
|
844 | 844 | $count = 1; |
845 | 845 | } |
846 | 846 | |
847 | - $out .= $string[ $i ]; |
|
847 | + $out .= $string[$i]; |
|
848 | 848 | } else { |
849 | 849 | if (count($temp) === 0) { |
850 | 850 | $count = ($ordinal < 224) ? 2 : 3; |
@@ -854,15 +854,15 @@ discard block |
||
854 | 854 | |
855 | 855 | if (count($temp) === $count) { |
856 | 856 | $number = ($count === 3) |
857 | - ? (($temp[ 0 ] % 16) * 4096) + (($temp[ 1 ] % 64) * 64) + ($temp[ 2 ] % 64) |
|
858 | - : (($temp[ 0 ] % 32) * 64) + ($temp[ 1 ] % 64); |
|
857 | + ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) |
|
858 | + : (($temp[0] % 32) * 64) + ($temp[1] % 64); |
|
859 | 859 | |
860 | - $out .= '&#' . $number . ';'; |
|
860 | + $out .= '&#'.$number.';'; |
|
861 | 861 | $count = 1; |
862 | 862 | $temp = []; |
863 | 863 | } // If this is the last iteration, just output whatever we have |
864 | 864 | elseif ($i === $s) { |
865 | - $out .= '&#' . implode(';', $temp) . ';'; |
|
865 | + $out .= '&#'.implode(';', $temp).';'; |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | } |