2 namespace TYPO3\CMS\Core\Utility;
37 if (is_object($haystack) || (
string)$haystack != $haystack || strlen($haystack) < 1) {
38 throw new \InvalidArgumentException(
39 '$haystack can not be interpreted as string or has no length',
43 if (is_object($needle) || (
string)$needle != $needle || strlen($needle) < 1) {
44 throw new \InvalidArgumentException(
45 '$needle can not be interpreted as string or has no length',
49 $stringLength = strlen($haystack);
50 $needleLength = strlen($needle);
51 return strrpos((
string)$haystack, (
string)$needle, 0) === $stringLength - $needleLength;
66 if (is_object($haystack) || $haystack === null || (
string)$haystack != $haystack) {
67 throw new \InvalidArgumentException(
68 '$haystack can not be interpreted as string',
72 if (is_object($needle) || (
string)$needle != $needle || strlen($needle) < 1) {
73 throw new \InvalidArgumentException(
74 '$needle can not be interpreted as string or has zero length',
78 $haystack = (string)$haystack;
79 $needle = (string)$needle;
80 return $needle !==
'' && strpos($haystack, $needle) === 0;
92 public static function endsWith($haystack, $needle)
95 if (is_object($haystack) || $haystack === null || (
string)$haystack != $haystack) {
96 throw new \InvalidArgumentException(
97 '$haystack can not be interpreted as string',
101 if (is_object($needle) || (
string)$needle != $needle || strlen($needle) < 1) {
102 throw new \InvalidArgumentException(
103 '$needle can not be interpreted as string or has no length',
107 $haystackLength = strlen($haystack);
108 $needleLength = strlen($needle);
109 if (!$haystackLength || $needleLength > $haystackLength) {
112 $position = strrpos((
string)$haystack, (
string)$needle);
113 return $position !==
false && $position === $haystackLength - $needleLength;
125 $uniqueId = uniqid($prefix,
true);
126 return str_replace(
'.',
'', $uniqueId);