Skip to content

Commit 96ba847

Browse files
committed
feat(string): add new method for repeat string
Signed-off-by: inhere <[email protected]>
1 parent c43da5a commit 96ba847

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Str/StringHelper.php

+11
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ public static function padByWidth($str, $padLen, string $padStr = ' ', int $padT
117117
return $padType === STR_PAD_RIGHT ? $str . $buildString : $buildString . $str;
118118
}
119119

120+
/**
121+
* @param string|int $str
122+
* @param string|int $times
123+
*
124+
* @return string
125+
*/
126+
public static function repeat($str, $times): string
127+
{
128+
return str_repeat((string)$str, (int)$times);
129+
}
130+
120131
////////////////////////////////////////////////////////////
121132
/// Security
122133
////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)