File tree 2 files changed +29
-3
lines changed
2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,20 @@ public static function isAssoc(array $array): bool
81
81
return array_keys ($ keys ) !== $ keys ;
82
82
}
83
83
84
+ /**
85
+ * check is a list array
86
+ *
87
+ * @param array $arr
88
+ *
89
+ * @return bool
90
+ */
91
+ public static function isList (array $ arr ): bool
92
+ {
93
+ $ keys = array_keys ($ arr );
94
+
95
+ return array_keys ($ keys ) === $ keys ;
96
+ }
97
+
84
98
/**
85
99
* @param mixed $array
86
100
*
Original file line number Diff line number Diff line change @@ -460,13 +460,25 @@ public static function shellQuote(string $arg): string
460
460
return $ arg ;
461
461
}
462
462
463
+ return self ::textQuote ($ arg );
464
+ }
465
+
466
+ /**
467
+ * Quote text on exist ', ", SPACE
468
+ *
469
+ * @param string $text
470
+ *
471
+ * @return string
472
+ */
473
+ public static function textQuote (string $ text ): string
474
+ {
463
475
$ quote = '' ;
464
- if (str_contains ($ arg , '" ' )) {
476
+ if (str_contains ($ text , '" ' )) {
465
477
$ quote = "' " ;
466
- } elseif ($ arg === '' || str_contains ($ arg , "' " ) || str_contains ($ arg , ' ' )) {
478
+ } elseif ($ text === '' || str_contains ($ text , "' " ) || str_contains ($ text , ' ' )) {
467
479
$ quote = '" ' ;
468
480
}
469
481
470
- return $ quote ? "$ quote$ arg $ quote " : $ arg ;
482
+ return $ quote ? "$ quote$ text $ quote " : $ text ;
471
483
}
472
484
}
You can’t perform that action at this time.
0 commit comments