File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Expand file tree Collapse file tree 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
8181 return array_keys ($ keys ) !== $ keys ;
8282 }
8383
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+
8498 /**
8599 * @param mixed $array
86100 *
Original file line number Diff line number Diff line change @@ -460,13 +460,25 @@ public static function shellQuote(string $arg): string
460460 return $ arg ;
461461 }
462462
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+ {
463475 $ quote = '' ;
464- if (str_contains ($ arg , '" ' )) {
476+ if (str_contains ($ text , '" ' )) {
465477 $ quote = "' " ;
466- } elseif ($ arg === '' || str_contains ($ arg , "' " ) || str_contains ($ arg , ' ' )) {
478+ } elseif ($ text === '' || str_contains ($ text , "' " ) || str_contains ($ text , ' ' )) {
467479 $ quote = '" ' ;
468480 }
469481
470- return $ quote ? "$ quote$ arg $ quote " : $ arg ;
482+ return $ quote ? "$ quote$ text $ quote " : $ text ;
471483 }
472484}
You can’t perform that action at this time.
0 commit comments