@@ -38,7 +38,7 @@ class Util {
38
38
* @return string
39
39
* code name
40
40
*/
41
- public static function httpCode ($ code ) {
41
+ public static function getHttpStatus ($ code ) {
42
42
$ http_codes = [
43
43
100 => 'Continue ' ,
44
44
101 => 'Switching Protocols ' ,
@@ -100,10 +100,6 @@ public static function httpCode($code) {
100
100
return isset ($ http_codes [$ code ]) ? $ http_codes [$ code ] : 'Unknown code ' ;
101
101
}
102
102
103
- public static function http_code ($ code ) {
104
- return self ::httpCode ($ code );
105
- }
106
-
107
103
public static function get ($ field , $ source = null , $ default = null , $ possible_values = []) {
108
104
$ source = is_null ($ source ) ? $ _GET : $ source ;
109
105
if (is_array ($ source )) {
@@ -228,28 +224,16 @@ public static function getOptions($config, &$message = null) {
228
224
} else return $ values ;
229
225
}
230
226
231
- public static function get_options ($ config , &$ message = null ) {
232
- return self ::getOptions ($ config , $ message );
233
- }
234
-
235
227
public static function isPjax () {
236
228
return isset ($ _SERVER ['HTTP_X_PJAX ' ]) && $ _SERVER ['HTTP_X_PJAX ' ] == true ;
237
229
}
238
230
239
- public static function is_pjax () {
240
- return self ::isPjax ();
241
- }
242
-
243
231
public static function inString ($ needle , $ string ) {
244
232
if (is_array ($ needle )) {
245
233
return preg_match ('/\b ' .implode ('\b|\b ' , $ needle ).'\b/i ' , $ string ) == 1 ;
246
234
} else return stripos ($ string , $ needle ) !== false ;
247
235
}
248
236
249
- public static function in_tring ($ needle , $ string ) {
250
- return self ::inString ($ needle , $ string );
251
- }
252
-
253
237
public static function explodeIds ($ src , $ separator = '; ' ) {
254
238
$ text = is_array ($ src ) ? implode ('; ' , $ src ) : $ src ;
255
239
$ raw = preg_replace ('/\s+/i ' , $ separator , $ text );
@@ -258,20 +242,12 @@ public static function explodeIds($src, $separator = ';') {
258
242
}));
259
243
}
260
244
261
- public static function explode_ids ($ src , $ separator = '; ' ) {
262
- return self ::explodeIds ($ src , $ separator );
263
- }
264
-
265
245
public static function explodeClean ($ src , $ separator = '; ' ) {
266
246
$ text = is_array ($ src ) ? implode ($ separator , $ src ) : $ src ;
267
247
$ raw = preg_replace ('/\s+/i ' , $ separator , $ text );
268
248
return array_values (array_filter (explode ($ separator , $ raw ), 'strlen ' ));
269
249
}
270
250
271
- public static function explode_clean ($ src , $ separator = '; ' ) {
272
- return self ::explode_clean ($ src , $ separator );
273
- }
274
-
275
251
public static function implodeAnd ($ arr ) {
276
252
if (!is_array ($ arr )) return $ arr ;
277
253
$ first_key = key (array_slice ($ arr , 0 , 1 , TRUE ));
@@ -286,10 +262,6 @@ public static function implodeAnd($arr) {
286
262
return ltrim ($ result );
287
263
}
288
264
289
- public static function implode_and ($ arr ) {
290
- return self ::implodeAnd ($ arr );
291
- }
292
-
293
265
/**
294
266
* encode and print the result to json (used for ajax routines)
295
267
* @param string $status status
@@ -319,10 +291,6 @@ public static function printStatus($status = 200, $data = [], $options = JSON_PR
319
291
else echo $ json ;
320
292
}
321
293
322
- public static function print_status ($ status = 200 , $ data = [], $ options = JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK , $ return = false ) {
323
- return self ::printStatus ($ status , $ options , $ return );
324
- }
325
-
326
294
/**
327
295
* Check params of an array/object provided by the given required keys
328
296
* @param mixed $required array or object that are required
@@ -343,18 +311,10 @@ public static function verifyFields($required, $fields = null, &$missing = []) {
343
311
return $ missing ? false : true ;
344
312
}
345
313
346
- public static function verify_fields ($ required , $ fields = null , &$ missing = []) {
347
- return self ::verifyFields ($ required , $ fields , $ missing );
348
- }
349
-
350
314
public static function isAjax () {
351
315
return !empty ($ _SERVER ['HTTP_X_REQUESTED_WITH ' ]) && strtolower ($ _SERVER ['HTTP_X_REQUESTED_WITH ' ]) == 'xmlhttprequest ' ;
352
316
}
353
317
354
- public static function is_ajax () {
355
- return self ::isAjax ();
356
- }
357
-
358
318
/**
359
319
* check if the running script is in CLI mode
360
320
* @return boolean [description]
@@ -363,10 +323,6 @@ public static function isCli() {
363
323
return php_sapi_name () == 'cli ' || !isset ($ _SERVER ["REQUEST_METHOD " ]);
364
324
}
365
325
366
- public static function is_cli () {
367
- return self ::isCli ();
368
- }
369
-
370
326
/**
371
327
* Convert a string to friendly SEO string
372
328
* @param string $text input
@@ -415,10 +371,6 @@ public static function setValues($defaults, $values, $default_key = "") {
415
371
return $ defaults ;
416
372
}
417
373
418
- public static function set_values ($ defaults , $ values , $ default_key = "" ) {
419
- return self ::setValues ($ defaults , $ values , $ default_key = "" );
420
- }
421
-
422
374
/**
423
375
* Read CSV from URL or File
424
376
* @param string $filename Filename
@@ -462,10 +414,6 @@ public static function readCsv($filename, $with_header = true, $headers = null,
462
414
return $ data ;
463
415
}
464
416
465
- public static function read_csv ($ filename , $ with_header = true , $ headers = null , $ delimiter = ', ' ) {
466
- return self ::readCsv ($ filename , $ with_header , $ headers , $ delimiter );
467
- }
468
-
469
417
/**
470
418
* Parse email address string
471
419
* @param string $str string input
@@ -503,10 +451,6 @@ public static function parseEmail($str, $separator = ",") {
503
451
return $ all ;
504
452
}
505
453
506
- public static function parse_email ($ str , $ separator = ", " ) {
507
- return self ::parseEmail ($ str , $ separator );
508
- }
509
-
510
454
/**
511
455
* Store client session info to an object
512
456
* @return stdClass returns the object containing details of the session
@@ -520,10 +464,6 @@ public static function getSessionInfo() {
520
464
return $ result ;
521
465
}
522
466
523
- public static function get_session_info () {
524
- return self ::getSessionInfo ();
525
- }
526
-
527
467
public static function truncate ($ string , $ limit , $ break = " " , $ pad = "… " ) {
528
468
// return with no change if string is shorter than $limit
529
469
if (strlen ($ string ) <= $ limit ) return $ string ;
@@ -575,10 +515,6 @@ public static function getClientIp() {
575
515
return $ ipaddress ;
576
516
}
577
517
578
- public static function get_client_ip () {
579
- return self ::getClientIp ();
580
- }
581
-
582
518
/**
583
519
* Get your browser's info
584
520
* @return stdClass returns the object containing the info of your browser
@@ -656,10 +592,6 @@ public static function getBrowserInfo() {
656
592
];
657
593
}
658
594
659
- public static function get_browser_info () {
660
- return self ::getBrowserInfo ();
661
- }
662
-
663
595
/**
664
596
* Returns an base64 encoded encrypted string
665
597
*/
@@ -697,38 +629,10 @@ public static function setStatus($status) {
697
629
http_response_code ($ status );
698
630
}
699
631
700
- public static function set_status ($ status ) {
701
- return self ::setStatus ($ status );
702
- }
703
-
704
632
public static function setContentType ($ type = 'application/json ' ) {
705
633
header ('Content-Type: ' . $ type );
706
634
}
707
635
708
- public static function set_content_type ($ type = 'application/json ' ) {
709
- self ::setContentType ();
710
- }
711
-
712
- public static function encodeResult ($ result , $ format = 'json ' ) {
713
- switch ($ format ) {
714
- case 'json ' :
715
- self ::setContentType ('application/json ' );
716
- echo json_encode ($ result );
717
- break ;
718
- case 'xml ' :
719
- self ::setContentType ('text/xml ' );
720
- $ xml = new XMLHelper ('Response ' );
721
- echo $ xml ->to_xml ($ result );
722
- break ;
723
- default :
724
- echo $ result ;
725
- }
726
- }
727
-
728
- public static function encode_result ($ result , $ format = 'json ' ) {
729
- self ::encodeResult ($ result , $ format );
730
- }
731
-
732
636
public static function debug ($ var , $ options = null , $ return = false ) {
733
637
$ is_cli = self ::isCli ();
734
638
$ is_ajax = self ::isAjax ();
@@ -778,10 +682,6 @@ public static function randomInt($min, $max) {
778
682
return $ min + $ rnd ;
779
683
}
780
684
781
- public static function random_int ($ min , $ max ) {
782
- return self ::randomInt ($ min , $ max );
783
- }
784
-
785
685
public static function token ($ length = 16 ) {
786
686
$ token = "" ;
787
687
$ codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ " ;
@@ -804,10 +704,6 @@ public static function urlBase64Decode($str) {
804
704
]));
805
705
}
806
706
807
- public static function url_base64_decode ($ str ) {
808
- return self ::urlBase64Decode ($ str );
809
- }
810
-
811
707
public static function urlBase64Encode ($ str ) {
812
708
return strtr (base64_encode ($ str ) , [
813
709
'+ ' => '- ' ,
@@ -816,10 +712,6 @@ public static function urlBase64Encode($str) {
816
712
]);
817
713
}
818
714
819
- public static function url_base64_encode ($ str ) {
820
- return self ::urlBase64Encode ($ str );
821
- }
822
-
823
715
/**
824
716
* redirect()
825
717
*
@@ -846,10 +738,6 @@ public static function formatAddress($data) {
846
738
return implode (', ' , array_filter (array_map (function ($ component ) { return trim (self ::br2nl ($ component )); }, $ components )));
847
739
}
848
740
849
- public static function format_address ($ data ) {
850
- return self ::formatAddress ($ data );
851
- }
852
-
853
741
/**
854
742
* timeInWords()
855
743
*
@@ -880,10 +768,6 @@ public static function timeInWords($date, $with_time = true) {
880
768
return $ return ;
881
769
}
882
770
883
- public static function time_in_words ($ date , $ with_time = true ) {
884
- return self ::timeInWords ($ date , $ with_time );
885
- }
886
-
887
771
/**
888
772
* escapeHtml()
889
773
*
@@ -902,10 +786,6 @@ public static function escapeHtml($src, $nl2br = false) {
902
786
}
903
787
}
904
788
905
- public static function escape_html ($ src , $ nl2br = false ) {
906
- return self ::escapeHtml ($ src , $ nl2br );
907
- }
908
-
909
789
public static function descapeHtml ($ src ) {
910
790
if (is_array ($ src )) {
911
791
return array_map ([__CLASS__ , 'descapeHtml ' ], $ src );
@@ -918,14 +798,6 @@ public static function descapeHtml($src) {
918
798
}
919
799
}
920
800
921
- public static function descape_html ($ src ) {
922
- return self ::descapeHtml ($ src );
923
- }
924
-
925
- /*public static function br2empty($text) {
926
- return preg_replace('/<br\s*\/?>/i', '', $text);
927
- }*/
928
-
929
801
public static function br2nl ($ text ) {
930
802
return preg_replace ('/<br\s*\/?>/i ' , EOL , $ text );
931
803
}
@@ -946,10 +818,6 @@ public static function toArray($object) {
946
818
], $ object );
947
819
}
948
820
949
- public static function to_array ($ object ) {
950
- return self ::toArray ($ object );
951
- }
952
-
953
821
/**
954
822
* Convert an array to an object
955
823
* @param array $array The array to convert
@@ -967,10 +835,6 @@ public static function toObject($array, $recursive = false) {
967
835
else return $ array ;
968
836
}
969
837
970
- public static function to_object ($ array , $ recursive = false ) {
971
- return self ::toObject ($ array , $ recursive );
972
- }
973
-
974
838
public static function unzip ($ zip_file , $ extract_path = null ) {
975
839
$ zip = new \ZipArchive ;
976
840
if ($ zip ->open ($ zip_file )) {
@@ -996,10 +860,6 @@ public static function formatPhone($input, $country_code = 1) {
996
860
return $ input ;
997
861
}
998
862
999
- public static function format_phone ($ input , $ country_code = 1 ) {
1000
- return self ::formatPhone ($ input , $ country_code );
1001
- }
1002
-
1003
863
public static function formatSsn ($ input ) {
1004
864
$ clean_input = substr (preg_replace ('/\D+/i ' , '' , $ input ), -9 );
1005
865
if (preg_match ('/^(\d{3})(\d{2})(\d{4})$/ ' , $ clean_input , $ matches )) {
@@ -1010,10 +870,6 @@ public static function formatSsn($input) {
1010
870
return $ input ;
1011
871
}
1012
872
1013
- public static function format_ssn ($ input ) {
1014
- return self ::formatSsn ($ input );
1015
- }
1016
-
1017
873
/**
1018
874
* Obtain a brand constant from a PAN
1019
875
* https://stackoverflow.com/a/21617574/3685987
@@ -1114,10 +970,6 @@ public static function getCardType($pan, $include_sub_types = false) {
1114
970
return 'unknown ' ; //unknown for this system
1115
971
}
1116
972
1117
- public static function get_card_type ($ pan , $ include_sub_types = false ) {
1118
- return self ::getCardType ($ pan , $ include_sub_types );
1119
- }
1120
-
1121
973
/**
1122
974
* Create a compressed zip file
1123
975
* @param array $files files (filename => file_location)
@@ -1194,10 +1046,6 @@ public static function parseGeom($ps) {
1194
1046
//array of arrays of LatLng objects, or empty array
1195
1047
return $ arr ;
1196
1048
}
1197
-
1198
- public static function parse_geom ($ ps ) {
1199
- return self ::parseGeom ($ ps );
1200
- }
1201
1049
}
1202
1050
1203
1051
?>
0 commit comments