Lines Matching refs:string
10 * A class with string utility
23 * @return string
25 static function truncateString($myString, $length): string
36 * @param $string
37 * @return string - the string without any carriage return
38 * Used to compare string without worrying about carriage return
40 public static function normalized($string)
42 return str_replace("\n", "", $string);
63 * No transformation if it's a string
72 $string = var_export($value, true);
75 $lastCharacterIndex = strlen($string) - 1;
76 if ($string[0] === "'" && $string[$lastCharacterIndex] === "'") {
77 $string = substr($string, 1, strlen($string) - 2);
79 return $string;
98 $string = var_export($value, true);
99 LogUtility::msg("The type of the value ($string) is unknown and could not be properly cast to string", LogUtility::LVL_MSG_WARNING);
100 return $string;
105 * Add an EOL if not present at the end of the string
120 * Delete the string from the end
123 * @param $string
125 public static function rtrim(&$doc, $string)
132 $string = trim($string);
133 $length = strlen($doc) - strlen($string);
134 if (substr($doc, $length) === $string) {
141 * Delete the string from the beginning
144 * @param $string
146 public static function ltrim(&$doc, $string)
150 $string = trim($string);
151 $length = strlen($string);
152 if (substr($doc, 0, $length) === $string) {
223 public static function endWiths($string, $suffix)
225 $suffixStartPosition = strlen($string) - strlen($suffix);
226 return strrpos($string, $suffix) === $suffixStartPosition;
229 public static function explodeAndTrim($string, $delimiter = ",")
231 return array_map('trim', explode($delimiter, $string));
243 public static function startWiths($string, $prefix)
245 return strrpos($string, $prefix) === 0;
249 * @param $string
253 public static function getWords($string, $separatorsCharacters = null): array
264 $string = str_replace($separatorsCharacters, " ", $string);
266 $string = preg_replace("/\s{2,}/", " ", $string);
268 $string = trim($string);
270 return explode(" ", $string);