Skip to content

Commit 12170bb

Browse files
committed
v2
1 parent c8a8628 commit 12170bb

File tree

1 file changed

+1
-153
lines changed

1 file changed

+1
-153
lines changed

src/Util.php

Lines changed: 1 addition & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Util {
3838
* @return string
3939
* code name
4040
*/
41-
public static function httpCode($code) {
41+
public static function getHttpStatus($code) {
4242
$http_codes = [
4343
100 => 'Continue',
4444
101 => 'Switching Protocols',
@@ -100,10 +100,6 @@ public static function httpCode($code) {
100100
return isset($http_codes[$code]) ? $http_codes[$code] : 'Unknown code';
101101
}
102102

103-
public static function http_code($code) {
104-
return self::httpCode($code);
105-
}
106-
107103
public static function get($field, $source = null, $default = null, $possible_values = []) {
108104
$source = is_null($source) ? $_GET : $source;
109105
if (is_array($source)) {
@@ -228,28 +224,16 @@ public static function getOptions($config, &$message = null) {
228224
} else return $values;
229225
}
230226

231-
public static function get_options($config, &$message = null) {
232-
return self::getOptions($config, $message);
233-
}
234-
235227
public static function isPjax() {
236228
return isset($_SERVER['HTTP_X_PJAX']) && $_SERVER['HTTP_X_PJAX'] == true;
237229
}
238230

239-
public static function is_pjax() {
240-
return self::isPjax();
241-
}
242-
243231
public static function inString($needle, $string) {
244232
if (is_array($needle)) {
245233
return preg_match('/\b'.implode('\b|\b', $needle).'\b/i', $string) == 1;
246234
} else return stripos($string, $needle) !== false;
247235
}
248236

249-
public static function in_tring($needle, $string) {
250-
return self::inString($needle, $string);
251-
}
252-
253237
public static function explodeIds($src, $separator = ';') {
254238
$text = is_array($src) ? implode(';', $src) : $src;
255239
$raw = preg_replace('/\s+/i', $separator, $text);
@@ -258,20 +242,12 @@ public static function explodeIds($src, $separator = ';') {
258242
}));
259243
}
260244

261-
public static function explode_ids($src, $separator = ';') {
262-
return self::explodeIds($src, $separator);
263-
}
264-
265245
public static function explodeClean($src, $separator = ';') {
266246
$text = is_array($src) ? implode($separator, $src) : $src;
267247
$raw = preg_replace('/\s+/i', $separator, $text);
268248
return array_values(array_filter(explode($separator, $raw), 'strlen'));
269249
}
270250

271-
public static function explode_clean($src, $separator = ';') {
272-
return self::explode_clean($src, $separator);
273-
}
274-
275251
public static function implodeAnd($arr) {
276252
if (!is_array($arr)) return $arr;
277253
$first_key = key(array_slice($arr, 0, 1, TRUE));
@@ -286,10 +262,6 @@ public static function implodeAnd($arr) {
286262
return ltrim($result);
287263
}
288264

289-
public static function implode_and($arr) {
290-
return self::implodeAnd($arr);
291-
}
292-
293265
/**
294266
* encode and print the result to json (used for ajax routines)
295267
* @param string $status status
@@ -319,10 +291,6 @@ public static function printStatus($status = 200, $data = [], $options = JSON_PR
319291
else echo $json;
320292
}
321293

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-
326294
/**
327295
* Check params of an array/object provided by the given required keys
328296
* @param mixed $required array or object that are required
@@ -343,18 +311,10 @@ public static function verifyFields($required, $fields = null, &$missing = []) {
343311
return $missing ? false : true;
344312
}
345313

346-
public static function verify_fields($required, $fields = null, &$missing = []) {
347-
return self::verifyFields($required, $fields, $missing);
348-
}
349-
350314
public static function isAjax() {
351315
return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
352316
}
353317

354-
public static function is_ajax() {
355-
return self::isAjax();
356-
}
357-
358318
/**
359319
* check if the running script is in CLI mode
360320
* @return boolean [description]
@@ -363,10 +323,6 @@ public static function isCli() {
363323
return php_sapi_name() == 'cli' || !isset($_SERVER["REQUEST_METHOD"]);
364324
}
365325

366-
public static function is_cli() {
367-
return self::isCli();
368-
}
369-
370326
/**
371327
* Convert a string to friendly SEO string
372328
* @param string $text input
@@ -415,10 +371,6 @@ public static function setValues($defaults, $values, $default_key = "") {
415371
return $defaults;
416372
}
417373

418-
public static function set_values($defaults, $values, $default_key = "") {
419-
return self::setValues($defaults, $values, $default_key = "");
420-
}
421-
422374
/**
423375
* Read CSV from URL or File
424376
* @param string $filename Filename
@@ -462,10 +414,6 @@ public static function readCsv($filename, $with_header = true, $headers = null,
462414
return $data;
463415
}
464416

465-
public static function read_csv($filename, $with_header = true, $headers = null, $delimiter = ',') {
466-
return self::readCsv($filename, $with_header, $headers, $delimiter);
467-
}
468-
469417
/**
470418
* Parse email address string
471419
* @param string $str string input
@@ -503,10 +451,6 @@ public static function parseEmail($str, $separator = ",") {
503451
return $all;
504452
}
505453

506-
public static function parse_email($str, $separator = ",") {
507-
return self::parseEmail($str, $separator);
508-
}
509-
510454
/**
511455
* Store client session info to an object
512456
* @return stdClass returns the object containing details of the session
@@ -520,10 +464,6 @@ public static function getSessionInfo() {
520464
return $result;
521465
}
522466

523-
public static function get_session_info() {
524-
return self::getSessionInfo();
525-
}
526-
527467
public static function truncate($string, $limit, $break = " ", $pad = "…") {
528468
// return with no change if string is shorter than $limit
529469
if (strlen($string) <= $limit) return $string;
@@ -575,10 +515,6 @@ public static function getClientIp() {
575515
return $ipaddress;
576516
}
577517

578-
public static function get_client_ip() {
579-
return self::getClientIp();
580-
}
581-
582518
/**
583519
* Get your browser's info
584520
* @return stdClass returns the object containing the info of your browser
@@ -656,10 +592,6 @@ public static function getBrowserInfo() {
656592
];
657593
}
658594

659-
public static function get_browser_info() {
660-
return self::getBrowserInfo();
661-
}
662-
663595
/**
664596
* Returns an base64 encoded encrypted string
665597
*/
@@ -697,38 +629,10 @@ public static function setStatus($status) {
697629
http_response_code($status);
698630
}
699631

700-
public static function set_status($status) {
701-
return self::setStatus($status);
702-
}
703-
704632
public static function setContentType($type = 'application/json') {
705633
header('Content-Type: ' . $type);
706634
}
707635

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-
732636
public static function debug($var, $options = null, $return = false) {
733637
$is_cli = self::isCli();
734638
$is_ajax = self::isAjax();
@@ -778,10 +682,6 @@ public static function randomInt($min, $max) {
778682
return $min + $rnd;
779683
}
780684

781-
public static function random_int($min, $max) {
782-
return self::randomInt($min, $max);
783-
}
784-
785685
public static function token($length = 16) {
786686
$token = "";
787687
$codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -804,10 +704,6 @@ public static function urlBase64Decode($str) {
804704
]));
805705
}
806706

807-
public static function url_base64_decode($str) {
808-
return self::urlBase64Decode($str);
809-
}
810-
811707
public static function urlBase64Encode($str) {
812708
return strtr(base64_encode($str) , [
813709
'+' => '-',
@@ -816,10 +712,6 @@ public static function urlBase64Encode($str) {
816712
]);
817713
}
818714

819-
public static function url_base64_encode($str) {
820-
return self::urlBase64Encode($str);
821-
}
822-
823715
/**
824716
* redirect()
825717
*
@@ -846,10 +738,6 @@ public static function formatAddress($data) {
846738
return implode(', ', array_filter(array_map(function($component) { return trim(self::br2nl($component)); }, $components)));
847739
}
848740

849-
public static function format_address($data) {
850-
return self::formatAddress($data);
851-
}
852-
853741
/**
854742
* timeInWords()
855743
*
@@ -880,10 +768,6 @@ public static function timeInWords($date, $with_time = true) {
880768
return $return;
881769
}
882770

883-
public static function time_in_words($date, $with_time = true) {
884-
return self::timeInWords($date, $with_time);
885-
}
886-
887771
/**
888772
* escapeHtml()
889773
*
@@ -902,10 +786,6 @@ public static function escapeHtml($src, $nl2br = false) {
902786
}
903787
}
904788

905-
public static function escape_html($src, $nl2br = false) {
906-
return self::escapeHtml($src, $nl2br);
907-
}
908-
909789
public static function descapeHtml($src) {
910790
if (is_array($src)) {
911791
return array_map([__CLASS__, 'descapeHtml'], $src);
@@ -918,14 +798,6 @@ public static function descapeHtml($src) {
918798
}
919799
}
920800

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-
929801
public static function br2nl($text) {
930802
return preg_replace('/<br\s*\/?>/i', EOL, $text);
931803
}
@@ -946,10 +818,6 @@ public static function toArray($object) {
946818
], $object);
947819
}
948820

949-
public static function to_array($object) {
950-
return self::toArray($object);
951-
}
952-
953821
/**
954822
* Convert an array to an object
955823
* @param array $array The array to convert
@@ -967,10 +835,6 @@ public static function toObject($array, $recursive = false) {
967835
else return $array;
968836
}
969837

970-
public static function to_object($array, $recursive = false) {
971-
return self::toObject($array, $recursive);
972-
}
973-
974838
public static function unzip($zip_file, $extract_path = null) {
975839
$zip = new \ZipArchive;
976840
if ($zip->open($zip_file)) {
@@ -996,10 +860,6 @@ public static function formatPhone($input, $country_code = 1) {
996860
return $input;
997861
}
998862

999-
public static function format_phone($input, $country_code = 1) {
1000-
return self::formatPhone($input, $country_code);
1001-
}
1002-
1003863
public static function formatSsn($input) {
1004864
$clean_input = substr(preg_replace('/\D+/i', '', $input), -9);
1005865
if (preg_match('/^(\d{3})(\d{2})(\d{4})$/', $clean_input, $matches)) {
@@ -1010,10 +870,6 @@ public static function formatSsn($input) {
1010870
return $input;
1011871
}
1012872

1013-
public static function format_ssn($input) {
1014-
return self::formatSsn($input);
1015-
}
1016-
1017873
/**
1018874
* Obtain a brand constant from a PAN
1019875
* https://stackoverflow.com/a/21617574/3685987
@@ -1114,10 +970,6 @@ public static function getCardType($pan, $include_sub_types = false) {
1114970
return 'unknown'; //unknown for this system
1115971
}
1116972

1117-
public static function get_card_type($pan, $include_sub_types = false) {
1118-
return self::getCardType($pan, $include_sub_types);
1119-
}
1120-
1121973
/**
1122974
* Create a compressed zip file
1123975
* @param array $files files (filename => file_location)
@@ -1194,10 +1046,6 @@ public static function parseGeom($ps) {
11941046
//array of arrays of LatLng objects, or empty array
11951047
return $arr;
11961048
}
1197-
1198-
public static function parse_geom($ps) {
1199-
return self::parseGeom($ps);
1200-
}
12011049
}
12021050

12031051
?>

0 commit comments

Comments
 (0)