4
4
5
5
use Closure ;
6
6
use Illuminate \Support \Traits \Macroable ;
7
- use JsonException ;
8
7
use League \CommonMark \Environment \Environment ;
9
8
use League \CommonMark \Extension \GithubFlavoredMarkdownExtension ;
10
9
use League \CommonMark \Extension \InlinesOnly \InlinesOnlyExtension ;
@@ -546,17 +545,7 @@ public static function isJson($value)
546
545
return false ;
547
546
}
548
547
549
- if (function_exists ('json_validate ' )) {
550
- return json_validate ($ value , 512 );
551
- }
552
-
553
- try {
554
- json_decode ($ value , true , 512 , JSON_THROW_ON_ERROR );
555
- } catch (JsonException ) {
556
- return false ;
557
- }
558
-
559
- return true ;
548
+ return json_validate ($ value , 512 );
560
549
}
561
550
562
551
/**
@@ -906,17 +895,7 @@ public static function numbers($value)
906
895
*/
907
896
public static function padBoth ($ value , $ length , $ pad = ' ' )
908
897
{
909
- if (function_exists ('mb_str_pad ' )) {
910
- return mb_str_pad ($ value , $ length , $ pad , STR_PAD_BOTH );
911
- }
912
-
913
- $ short = max (0 , $ length - mb_strlen ($ value ));
914
- $ shortLeft = floor ($ short / 2 );
915
- $ shortRight = ceil ($ short / 2 );
916
-
917
- return mb_substr (str_repeat ($ pad , $ shortLeft ), 0 , $ shortLeft ).
918
- $ value .
919
- mb_substr (str_repeat ($ pad , $ shortRight ), 0 , $ shortRight );
898
+ return mb_str_pad ($ value , $ length , $ pad , STR_PAD_BOTH );
920
899
}
921
900
922
901
/**
@@ -929,13 +908,7 @@ public static function padBoth($value, $length, $pad = ' ')
929
908
*/
930
909
public static function padLeft ($ value , $ length , $ pad = ' ' )
931
910
{
932
- if (function_exists ('mb_str_pad ' )) {
933
- return mb_str_pad ($ value , $ length , $ pad , STR_PAD_LEFT );
934
- }
935
-
936
- $ short = max (0 , $ length - mb_strlen ($ value ));
937
-
938
- return mb_substr (str_repeat ($ pad , $ short ), 0 , $ short ).$ value ;
911
+ return mb_str_pad ($ value , $ length , $ pad , STR_PAD_LEFT );
939
912
}
940
913
941
914
/**
@@ -948,13 +921,7 @@ public static function padLeft($value, $length, $pad = ' ')
948
921
*/
949
922
public static function padRight ($ value , $ length , $ pad = ' ' )
950
923
{
951
- if (function_exists ('mb_str_pad ' )) {
952
- return mb_str_pad ($ value , $ length , $ pad , STR_PAD_RIGHT );
953
- }
954
-
955
- $ short = max (0 , $ length - mb_strlen ($ value ));
956
-
957
- return $ value .mb_substr (str_repeat ($ pad , $ short ), 0 , $ short );
924
+ return mb_str_pad ($ value , $ length , $ pad , STR_PAD_RIGHT );
958
925
}
959
926
960
927
/**
0 commit comments