@@ -60,25 +60,39 @@ static public function echoJson(int $response = 0, $message = null)
6060 echo json_encode (['response ' => $ response , 'message ' => $ message ]);
6161 }
6262
63+ /**
64+ * Check IF URL Exists
65+ *
66+ * @param string $url
67+ * @return bool
68+ */
69+ static public function urlExists ($ url )
70+ {
71+ $ ch = curl_init ($ url );
72+
73+ // Set cURL options
74+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
75+ curl_setopt ($ ch , CURLOPT_HEADER , true );
76+ curl_setopt ($ ch , CURLOPT_NOBODY , true );
77+ curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true ); // Follow redirects
78+
79+ // Execute cURL and get the HTTP status code
80+ $ httpCode = curl_exec ($ ch );
81+
82+ // Close cURL handle
83+ curl_close ($ ch );
84+
85+ return $ httpCode && preg_match ('/\b200\b/ ' , $ httpCode );
86+ }
87+
6388 /**
6489 * Check IF Internet is Available
65- *
90+ *
6691 * @return bool
6792 */
6893 static public function isInternetAvailable ()
6994 {
70- // Use cURL to make a request
71- $ request = curl_init ('https://www.google.com ' );
72- curl_setopt ($ request , CURLOPT_RETURNTRANSFER , true );
73- curl_setopt ($ request , CURLOPT_TIMEOUT , 5 );
74- curl_exec ($ request );
75-
76- // Check the HTTP response code
77- $ httpCode = curl_getinfo ($ request , CURLINFO_HTTP_CODE );
78- curl_close ($ request );
79-
80- // HTTP code 200 means the request was successful
81- return $ httpCode === 200 ;
95+ return self ::urlExists ('https://www.google.com ' );
8296 }
8397
8498 /**
@@ -511,11 +525,7 @@ static public function calPercentageBetweenNumbers(float|int $total = 0, float|i
511525 */
512526 static public function isArrayDuplicate (?array $ data = [])
513527 {
514- if (count ($ data ) > count (array_unique ($ data ))){
515- return true ;
516- }
517-
518- return false ;
528+ return Str::arrayDuplicate ($ data );
519529 }
520530
521531 /**
@@ -527,11 +537,7 @@ static public function isArrayDuplicate(?array $data = [])
527537 */
528538 static public function isArraySame (?array $ data = [])
529539 {
530- if (count ($ data ) > count (array_unique ($ data ))){
531- return true ;
532- }
533-
534- return false ;
540+ return Str::arraySame ($ data );
535541 }
536542
537543 /**
@@ -547,34 +553,31 @@ static public function sortArray(?array $data = [], ?string $type = 'sort')
547553 {
548554 switch ($ type ) {
549555 case 'rsort ' :
550- rsort ($ data ); return $ data ; // sort arrays in descending order
556+ rsort ($ data ); // sort arrays in descending order
551557 break ;
552-
558+
553559 case 'asort ' :
554- asort ($ data );
555- return asort ($ data ); //sort associative arrays in ascending order, according to the value
560+ asort ($ data ); // sort associative arrays in ascending order, according to the value
556561 break ;
557-
562+
558563 case 'ksort ' :
559- ksort ($ data );
560- return $ data ; //sort associative arrays in ascending order, according to the key
564+ ksort ($ data ); // sort associative arrays in ascending order, according to the key
561565 break ;
562-
566+
563567 case 'arsort ' :
564- arsort ($ data );
565- return $ data ; //sort associative arrays in descending order, according to the value
568+ arsort ($ data ); // sort associative arrays in descending order, according to the value
566569 break ;
567-
570+
568571 case 'krsort ' :
569- krsort ($ data );
570- return $ data ; //sort associative arrays in descending order, according to the value
572+ krsort ($ data ); // sort associative arrays in descending order, according to the value
571573 break ;
572574
573575 default :
574- sort ($ data );
575- return $ data ; //sort arrays in descending order
576+ sort ($ data ); // sort arrays in ascending order
576577 break ;
577578 }
579+
580+ return $ data ;
578581 }
579582
580583 /**
@@ -1162,7 +1165,7 @@ static public function platformIcon($platform = null, $os_name = null)
11621165 $ os_name = Str::lower ($ os_name );
11631166
11641167 // set path
1165- $ path = self ::stringReplacer ( __DIR__ );
1168+ $ path = self ::stringReplacer ( __DIR__ ) . DIRECTORY_SEPARATOR ;
11661169
11671170 // Create items data set
11681171 $ dataSet = [
@@ -1199,7 +1202,7 @@ static public function platformIcon($platform = null, $os_name = null)
11991202 static public function paymentIcon ($ payment = null )
12001203 {
12011204 // set path
1202- $ path = self ::stringReplacer ( __DIR__ );
1205+ $ path = self ::stringReplacer ( __DIR__ ) . DIRECTORY_SEPARATOR ;
12031206
12041207 // Create items data set
12051208 $ dataSet = [
0 commit comments